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

Popular posts from this blog

mysql - java.sql.SQLException Parameter index out of range (1 > number of parameters, which is 0) -

c - ALSA programming: how to stop immediately -