SQLiteDatabase 的 openOrCreateDatabase 和 Context 的区别?
Difference between openOrCreateDatabase of SQLiteDatabase and Context?
Android 在两个不同的 class 中有 openOrCreateDatabase
:SQLiteDatabase and Context。请问它们有什么区别?
与此同时,我正在使用单例 class 来维护我的数据库。如果我想在多个活动中使用同一个数据库,openOrCreateDatabase
哪个版本更合适?
关于您关于 Context.openOrCreateDatabase
和 SQLiteDatabase.openOrCreateDatabase
之间区别的问题,答案在于这句话:
Open a new private SQLiteDatabase associated with this Context's
application package.
Context.openOrCreateDatabase
创建位于应用程序私有数据文件夹中的数据库文件,而 SQLiteDatabase.openOrCreateDatabase
可以在您的应用程序具有写入权限的任何位置创建数据库。
关于你的第二个问题,我认为你选择使用哪一个并不重要。
Android 在两个不同的 class 中有 openOrCreateDatabase
:SQLiteDatabase and Context。请问它们有什么区别?
与此同时,我正在使用单例 class 来维护我的数据库。如果我想在多个活动中使用同一个数据库,openOrCreateDatabase
哪个版本更合适?
关于您关于 Context.openOrCreateDatabase
和 SQLiteDatabase.openOrCreateDatabase
之间区别的问题,答案在于这句话:
Open a new private SQLiteDatabase associated with this Context's application package.
Context.openOrCreateDatabase
创建位于应用程序私有数据文件夹中的数据库文件,而 SQLiteDatabase.openOrCreateDatabase
可以在您的应用程序具有写入权限的任何位置创建数据库。
关于你的第二个问题,我认为你选择使用哪一个并不重要。