SQLiteDatabase.openDatabase(...)VS getWritableDatabase [英] 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).
我的问题;是它更好地使用
的openDatabase(字符串路径,SQLiteDatabase.CursorFactory工厂,INT标志)
或使用SQLiteOpenHelper类的getWritableDatabase方法?
my question; is it better to use openDatabase (String path, SQLiteDatabase.CursorFactory factory, int flags) or to use getWritableDatabase method of the SQLiteOpenHelper class?
这是更有效率?
我习惯使用getWritableDatabase方法,这就需要上下文的过客,但我只是觉得没有它,我能做到,因为我不需要onUpgrade或SQliteOpenHelper的功能的onCreate
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.
推荐答案
getWritableDatabase
只是的 SQLiteOpenHelper
办法开幕数据库。
getWritableDatabase
is just SQLiteOpenHelper
's way of opening databases.
如果您不需要 SQLiteOpenHelper
时,你不需要调用 getWritableDatabase
或者
If you do not need SQLiteOpenHelper
, the you do not need to call getWritableDatabase
either.
这篇关于SQLiteDatabase.openDatabase(...)VS getWritableDatabase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!