I have a need that child table must not be deleted when parent is deleted.
So I have 2 tables:
"CREATE TABLE Book (ID integer primary key, locationID integer, "
+ "FOREIGN KEY (locationID) REFERENCES Location(ID))";
"CREATE TABLE Location (ID integer primary key)";
Then I delete location record:
getContentResolver().delete(LocationColumns.CONTENT_URI,
"ID=?",
new String[]{String.valueOf(locationID)});
However it gives me:
android.database.sqlite.SQLiteConstraintException: foreign key constraint failed (code 19)
Based on sqlite docs, it must be ON DELETE NO ACTION, I also tried to add separately ON DELETE NO ACTION, ON DELETE SET DEFAULT, but still gives me same error.
I am not sure why this happens, anyone can advise me?
Aucun commentaire:
Enregistrer un commentaire