[英]SQLiteDatabase.openDatabase vs SQLiteOpenHelper.getReadableDatabase
Is there any difference between these two methods?这两种方法有什么区别吗? Both return an opened SQLiteDatabase.
两者都返回一个打开的 SQLiteDatabase。 Both can create a database if one doesn't exist.
如果一个数据库不存在,两者都可以创建一个数据库。 SQLiteOpenHelper also has getWriteableDatabase when read/write is needed...
当需要读/写时,SQLiteOpenHelper 也有 getWriteableDatabase ......
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.
根据我看到的示例代码,我首先使用 SQLiteOpenHelper 创建我的数据库,然后在需要使用数据库时调用 SQLiteDatabase.openDatabase。
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()
. openDatabase()
更灵活,允许您指定语言环境等,但在大多数情况下,您不需要明确提供这些详细信息, Android 文档说要使用getReadableDatabase()
和getWriteableDatabase()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.