SQLiteDatabase.openDatabase vs SQLiteOpenHelper.getReadableDatabase

天大地大妈咪最大 提交于 2019-12-23 09:08:34

问题


Is there any difference between these two methods? Both return an opened SQLiteDatabase. Both can create a database if one doesn't exist. SQLiteOpenHelper also has getWriteableDatabase when read/write is needed...

Which method should I use and where? Based on sample code I've seen, I'm using SQLiteOpenHelper to create my database in the first place, but then calling SQLiteDatabase.openDatabase when I need to use the database.


回答1:


The openDatabase() is more flexible allowing you to specify locale etc. but for most circumstances where you don't need to explicitly supply those details the Android documentation says to use getReadableDatabase() and getWriteableDatabase().



来源:https://stackoverflow.com/questions/6193279/sqlitedatabase-opendatabase-vs-sqliteopenhelper-getreadabledatabase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!