Your database should delete rows from quizQuestions
in case someone is deleting from quizzes
or from questions
. It will ignore the entire foreign key constraint in case foreign key support is turned off and you have just regular columns that can contain any value.
SQLite defaults to PRAGMA foreign_keys = OFF
every time you open the database. It’s not a property of a table or of the schema.
In case you use SQLiteOpenHelper
put it in onOpen
. That is the place that is called every time the database is opened. onCreate
only once when the database is created.
What SQLiteOpenHelper
calls when you call getWriteableDatabase
for the first time is
onConfigure
every time, API Level >= 16 required- depending on the existence and version of the database file the following is called within an transaction
onCreate
if there is no database file. Typically, this happens only once in the entire lifetime of the app.onUpgrade
if the database version (PRAGMA user_version
– saved inside the database file) is less then the version supplied in SQLiteOpenHelper’s constructor. Happens every time you bump the version in your code.- Nothing if file exists and version matches.
onOpen
every time
If the same instance of SQLiteOpenHelper
already has an open database it will just return it and nothing of above happens.