There are two tables, in the main table there is a column name , which is the key for the child table. When I update the name , I do it like this:

 // перезаписываем данные обьекта public static void reloadObject(String oldName, String newName, String description, String date, Context context) { ContentValues cv = new ContentValues(); ObjectDB objectDB = new ObjectDB(context); SQLiteDatabase db = objectDB.getWritableDatabase(); cv.put(ObjectDB.objColumn.NAME, newName); cv.put(ObjectDB.objColumn.DESCRIPTION, description); cv.put(ObjectDB.objColumn.START_DATE, date); db.update(ObjectDB.dbTab.OBJECT, cv, ObjectDB.objColumn.NAME + " = ?", new String[]{oldName}); db.close(); } 

In the child table, this column is not updated, although in the table settings it is indicated:

 [object] TEXT REFERENCES geology_object([name]) ON DELETE RESTRICT ON UPDATE CASCADE, 

If you update the name in SQLite Expert Personal then everything is updated correctly. I use a ready-made database and insert it into a project using Android SQLiteAssetHelper

    2 answers 2

    Found the answer to your question, can someone come in handy. It was necessary to insert this line:

     db.setForeignKeyConstraintsEnabled(true); 

    before

     db.update(ObjectDB.dbTab.OBJECT, cv, ObjectDB.objColumn.NAME + " = ?", new String[]{oldName}); 

    and it all worked.

      I use a slightly different way. I overload method SQLiteOpenHelper.onOpen()

       @Override public void onOpen(SQLiteDatabase database) { super.onOpen(database); database.execSQL("PRAGMA foreign_keys=ON;"); } 

      also works, and the method is more universal, because setForeignKeyConstraintsEnabled() only works with API 16