android - How to enable programatically sqlite foreign key support? -
in documentation of sqlite syntax pragma foreign_keys = on;
enables foreign key support. code in android ?
you can override onopen in class extends sqliteopenhelper this:
@override public void onopen(sqlitedatabase db) { super.onopen(db); if (!db.isreadonly()) { db.execsql("pragma foreign_keys=on;"); } }
Comments
Post a Comment