如何使用 SQLite 数据库开发 Android 应用程序?
How to go about developing an Android app with SQLite database?
我想编写一个具有 SQLite 数据库的 Android 应用程序。
我看过 this question, but it (as well as the answer) is 7 years old, which has also been pointed by CommonsWare in a comment, in which they have also suggested to use this 图书馆。但是评论也是2013年的,最后一次入库commit也是2014年12月
另一方面,在this official guide中,他们说创建SQLite数据库的推荐方法是继承SQLiteOpenHelper
,从中可以推断出Google是现在推荐使用原生 Android API 来创建和使用数据库。
所以我的问题是我应该遵循什么方式?也就是说,截至 2016 年,在 Android 应用程序中创建、使用和传送 SQLite 数据库的推荐方法是什么?
The last commit in the library is also in Dec. 2014.
那个库做的不多,所以我不希望它发生变化。 SQLiteAssetHelper
工作正常。
但是,SQLiteAssetHelper
是针对特定问题的解决方案:使用应用程序运送数据库。
On the other hand, in this official guide, they are saying that the recommended method for creating an SQLite database is to subclass SQLiteOpenHelper, from which one can infer that Google is now recommending the use of native Android API to create and work with databases.
嗯,SQLiteAssetHelper
extends SQLiteOpenHelper
,它使用 "native Android API to create and work with databases"。
此外,SQLiteOpenHelper
确实对特定问题没有任何作用:使用应用程序运送数据库。
now as of 2016, what is the recommended way of creating and working with and shipping an SQLite database in an Android application?
鉴于"and shipping"位,强烈推荐SQLiteAssetHelper
。
相反,如果您 不 将数据库与您的应用程序一起发送 - 计算机程序员将其定义为 "having a database with a schema and data that you want to include in the shipped app to use as a starting point" - 那么只需使用 SQLiteOpenHelper
并定义您的数据库正在运行。
我想编写一个具有 SQLite 数据库的 Android 应用程序。
我看过 this question, but it (as well as the answer) is 7 years old, which has also been pointed by CommonsWare in a comment, in which they have also suggested to use this 图书馆。但是评论也是2013年的,最后一次入库commit也是2014年12月
另一方面,在this official guide中,他们说创建SQLite数据库的推荐方法是继承SQLiteOpenHelper
,从中可以推断出Google是现在推荐使用原生 Android API 来创建和使用数据库。
所以我的问题是我应该遵循什么方式?也就是说,截至 2016 年,在 Android 应用程序中创建、使用和传送 SQLite 数据库的推荐方法是什么?
The last commit in the library is also in Dec. 2014.
那个库做的不多,所以我不希望它发生变化。 SQLiteAssetHelper
工作正常。
但是,SQLiteAssetHelper
是针对特定问题的解决方案:使用应用程序运送数据库。
On the other hand, in this official guide, they are saying that the recommended method for creating an SQLite database is to subclass SQLiteOpenHelper, from which one can infer that Google is now recommending the use of native Android API to create and work with databases.
嗯,SQLiteAssetHelper
extends SQLiteOpenHelper
,它使用 "native Android API to create and work with databases"。
此外,SQLiteOpenHelper
确实对特定问题没有任何作用:使用应用程序运送数据库。
now as of 2016, what is the recommended way of creating and working with and shipping an SQLite database in an Android application?
鉴于"and shipping"位,强烈推荐SQLiteAssetHelper
。
相反,如果您 不 将数据库与您的应用程序一起发送 - 计算机程序员将其定义为 "having a database with a schema and data that you want to include in the shipped app to use as a starting point" - 那么只需使用 SQLiteOpenHelper
并定义您的数据库正在运行。