sqlite - Android On Delete Cascade not working properly -


i making android app in make 5 tables in 1 open helper class. facing problem while having on delete cascade in schema. know concept of on delete cascade. here copy 1 of 2 tables.

private static final string medicine_table  = "create table medicine_details (_mid integer primary key autoincrement, "                                                     + " medicine_name text, type text, take_with text, m_did integer not null,"                                                     + "foreign key(m_did) references doctor_details(did)"                                                     + " on delete cascade" + ");";  private static final string sch_tab         = "create table schedule_details(sid integer primary key autoincrement, "                                                     + "medi_stdate text,medi_end_date text,time_sch text,rept text, alarm_id number, "                                                     + "u_id integer not null, doc_id integer not null, mid integer not null, "                                                     + "foreign key(u_id) references member_details(_id)"                                                     + " on delete cascade,"                                                     + "foreign key(doc_id) references doctor_details(did)"                                                     + " on delete cascade,"                                                     + "foreign key(mid) references medicine_details(_mid)"                                                     + " on delete cascade" + ");"; 

whenever try delete medicine,it deletes medicine table not schedule table. here medicine table master table , schedule table child table.

you must override method open() can see in following example:

    @override public void onopen(sqlitedatabase db) {     super.onopen(db);     if (!db.isreadonly()) {         db.execsql("pragma foreign_keys=on;");     } } 

best regards


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -