Android 中使用的 SQLite 版本

发布于 2024-08-24 20:24:43 字数 113 浏览 4 评论 0原文

Android 使用哪个版本的 SQLite?

我想知道如何处理架构迁移。较新的 SQLite 版本支持 ALTER TABLE SQL 命令,这使我不必复制数据、删除表、重新创建表和重新插入数据。

What version of SQLite is used in Android?

I'm wondering how to handle schema migrations. The newer SQLite versions support an ALTER TABLE SQL command which save me from having to copy data, drop the table, recreate table and re-insert data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

标点 2024-08-31 20:24:44

以下是官方文档的链接,其中包括此答案中的要点: android.database.sqlite 包级 javadoc

用于获取框架 SQLite 版本的 Kotlin 代码(提示:只需在 Activity onCreate() 中添加一个断点,并在 中使用此代码>评估表达式...):

val version = android.database.sqlite.SQLiteDatabase.create(null).use {
    android.database.DatabaseUtils.stringForQuery(it, "SELECT sqlite_version()", null)
};
"Framework (API ${android.os.Build.VERSION.SDK_INT}) SQLite version: $version".also { println(it) }

使用模拟器(请注意,实际设备上的 SQLite 版本将至少指定):

API 级别*版本名称SQLite注释
3515V3.44.3请参阅 3.44.2版本控制签入,因为 3.44.3 链接不存在
3414U3.39.2右外连接和全外连接
3313T3.32.2< /a>
3212LSv23.32.2
3112S3.32.2
3011R3.28.0窗口函数
29103.22.0
2893.22.0
278.1Oreo3.19.4请参阅3.19.3版本控制签入,因为 3.19.4 链接不存在
268.0Oreo3.18.2使用的 O beta 版本 3.18.0
257.1.1牛轧糖3.9.2< /a>
247.0牛轧糖3.9.2
236.0Marshmallow3.8.10.2使用 M 预览版 1(SDK 级别 22)3.8.10
225.1.1Lollipop3.8.6.1请参阅 3.8.6版本控制签入,因为 3.8.6.1 链接不存在
215.0Lollipop3.8.6
204.4W.2Android Wear未知,没有可用的模拟器,但可能是 3.7.11 或 3.8.4.3
194.4KitKat3.7.11
184.3Jelly Bean3.7.11
174.2Jelly Bean3.7.11
16**4.1Jelly Bean3.7.11
154.0.3冰淇淋三明治3.7.4
14**4.0冰淇淋三明治< a href="https://www.sqlite.org/releaselog/3_7_4.html" rel="nofollow noreferrer">3.7.4
133.2蜂窝3.7.4
123.1蜂窝3.7.4
11**3.0蜂窝3.7.4
102.3.3姜饼3.6.22
92.3.1姜饼3.6.22
8**2.2Froyo3.6.22
72.1闪电泡芙3.5.9
41.6甜甜圈3.5.9
3**1.5纸杯蛋糕3.5.9

* Android API 级别链接显示 android.database.sqlite< 的位置/a> 包已更改。如果没有链接(例如 API 级别 17),则表示该包没有更改。

** 损坏的 SDK 链接,请参阅此处

注意:如果您希望您的应用使用相同版本要跨所有 Android 版本使用 SQLite,请考虑使用 Requery 的第三方 SQLite 支持库SQLCipher (如果您还想要加密)。

Here is a link to the official docs which include the main points in this answer: android.database.sqlite package-level javadoc

Kotlin code to get framework SQLite version (tip: just stick a breakpoint in your Activity onCreate() and use this code in Evaluate Expression...):

val version = android.database.sqlite.SQLiteDatabase.create(null).use {
    android.database.DatabaseUtils.stringForQuery(it, "SELECT sqlite_version()", null)
};
"Framework (API ${android.os.Build.VERSION.SDK_INT}) SQLite version: $version".also { println(it) }

Using the emulators (note, SQLite version on actual devices will be at least that specified):

API level*VersionNameSQLiteNotes
3515V3.44.3see 3.44.2 and version control check-ins because 3.44.3 link does not exist
3414U3.39.2RIGHT and FULL OUTER JOIN
3313T3.32.2
3212LSv23.32.2
3112S3.32.2
3011R3.28.0window functions
2910Q3.22.0
289Pie3.22.0
278.1Oreo3.19.4see 3.19.3 and version control check-ins because 3.19.4 link does not exist
268.0Oreo3.18.2O beta versions used 3.18.0
257.1.1Nougat3.9.2
247.0Nougat3.9.2
236.0Marshmallow3.8.10.2M Preview 1 (SDK level 22) used 3.8.10
225.1.1Lollipop3.8.6.1see 3.8.6 and version control check-ins because 3.8.6.1 link does not exist
215.0Lollipop3.8.6
204.4W.2Android Wearunknownno emulator available, but probably either 3.7.11 or 3.8.4.3
194.4KitKat3.7.11
184.3Jelly Bean3.7.11
174.2Jelly Bean3.7.11
16**4.1Jelly Bean3.7.11
154.0.3Ice Cream Sandwich3.7.4
14**4.0Ice Cream Sandwich3.7.4
133.2Honeycomb3.7.4
123.1Honeycomb3.7.4
11**3.0Honeycomb3.7.4
102.3.3Gingerbread3.6.22
92.3.1Gingerbread3.6.22
8**2.2Froyo3.6.22
72.1Eclair3.5.9
41.6Donut3.5.9
3**1.5Cupcake3.5.9

* Android API level links show where the android.database.sqlite package has changed. Where there is no link (e.g. API level 17), indicates no changes to that package.

** Broken SDK link, see here

Note: if you want your app to use the same version of SQLite across all Android versions, consider using Requery's 3rd party SQLite support library or SQLCipher (if you also want encryption).

回首观望 2024-08-31 20:24:44

尽管文档给出了 3.4.0 作为参考号,但如果执行以下 sql,您会注意到安装的 SQlite 数量要多得多:

Cursor cursor = SQLiteDatabase.create(null).rawQuery("select sqlite_version() AS sqlite_version", null);
String sqliteVersion = "";
while(cursor.moveToNext()){
   sqliteVersion += cursor.getString(0);
}

这只是一段用于检索 sqlite 版本的快速、肮脏的代码。例如,在搭载 Android 2.1 的 HTC Hero 上,我得到:3.5.9

在我的 Android 2.2 Nexus One 上,我什至得到了3.6.22

Although the documentation gives 3.4.0 as reference number, if you execute the following sql, you'll notice that there is a much higher number of SQlite installed:

Cursor cursor = SQLiteDatabase.create(null).rawQuery("select sqlite_version() AS sqlite_version", null);
String sqliteVersion = "";
while(cursor.moveToNext()){
   sqliteVersion += cursor.getString(0);
}

This is just a piece of quick, dirty code to retrieve the sqlite version. For instance on a HTC Hero with Android 2.1, I get: 3.5.9.

On my Nexus One with Android 2.2, I even get 3.6.22.

叹沉浮 2024-08-31 20:24:44
$ adb shell sqlite3 --version 
3.5.9

ADP1 1.6 和 ADP1 1.6 上相同2.1 模拟器。

$ adb shell sqlite3 --version 
3.5.9

Same on ADP1 1.6 & 2.1 emulator.

自此以后,行同陌路 2024-08-31 20:24:44

Andorid API 和支持的 SQLite 版本的简短概述。

输入图片此处描述

概述来自马克回答中的链接。

A short overview of the Andorid APIs and the supported SQLite versions.

enter image description here

The overview is from the link in Mark's answer.

暗地喜欢 2024-08-31 20:24:44

在 Room 中您可以查询

SELECT sqlite_version()

RG

In Room you can query

SELECT sqlite_version()

RG

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文