Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLiteDatabase.openDatabase(...) vs getWritableDatabase

I bundled a database with my app in the assets folder. At the first activity, I copy the database to the correct location perfectly (no problem here).

my question; is it better to use openDatabase (String path, SQLiteDatabase.CursorFactory factory, int flags) or to use getWritableDatabase method of the SQLiteOpenHelper class?

which is more efficient? I'm accustomed to using the getWritableDatabase method, which requires passing of Context, but I just feel I can do without it since I don't need the onUpgrade or onCreate function of the SQliteOpenHelper.

like image 803
Olumide Oyetoke Avatar asked Sep 01 '26 16:09

Olumide Oyetoke


1 Answers

getWritableDatabase is just SQLiteOpenHelper's way of opening databases.

If you do not need SQLiteOpenHelper, the you do not need to call getWritableDatabase either.

like image 113
CL. Avatar answered Sep 03 '26 04:09

CL.