Reputation: 35
I am familiar with the notion of the SQLiteOpenHelper class and its onCreate & onUpgrade method, but when is the database itself actually instantiated for the first time? Is it during installation of the app, or upon the first call of getWritableDatabase()/getReadableDatabase() ?
Thanks!
Upvotes: 1
Views: 37
Reputation: 10052
Database, as file on disk, is created when you call getWritableDatabase
or getReadableDatabase
.
Just read the docs of SQLiteOpenHelper constructor ;-)
Upvotes: 2
Reputation: 1006614
Is it during installation of the app
No.
upon the first call of getWritableDatabase()/getReadableDatabase() ?
Yes. This is why it is important to call those methods on a background thread, as how long they take depends upon whether or not the database needs to be created or upgraded.
Upvotes: 4