Should I prepare a empty DB inadvance while using the SQliteOpenHelper to create db tables ?
From the doc. of SQLiteOpenHelper, it states:
public abstract void onCreate (SQLiteDatabase db)
Called when the database is created for the first time. This is where the creation of tables and the initial population of the tables should happen.
It makes me confused:
1. When the db will be created and to triger the onCreate() method ?
2. Does the db will be created automatically if it is not existed ?
Thanks for the reviewing the question and help reponse !
The
onCreate()method will be invoked and the DB will be created when it is not found on the phone’s storage.If the DB exists but with an older version you’ll get a call to
onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)