Reputation: 19347
In the documentation of sqlite this syntax PRAGMA foreign_keys = ON;
enables foreign key support. What is the code in Android ?
Upvotes: 1
Views: 154
Reputation: 3150
You can override onOpen in your class that extends SQLiteOpenHelper like this:
@Override
public void onOpen(SQLiteDatabase db) {
super.onOpen(db);
if (!db.isReadOnly()) {
db.execSQL("PRAGMA foreign_keys=ON;");
}
}
Upvotes: 3