Android 中使用的 SQLite 版本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2421189/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:48:46  来源:igfitidea点击:

Version of SQLite used in Android?

databaseandroidsqliteschemamigration

提问by Eno

What is the version of SQLite used in Android?

Android 中使用的 SQLite 版本是多少?

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

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

回答by Mark

UPDATE OCT 2016: Here is a link to the updated official docs which includes the main points in this answer: android.database.sqlite package-level javadoc

2016 年 10 月更新:这是更新的官方文档的链接,其中包含此答案中的要点:android.database.sqlite 包级 javadoc

Using the emulators:

使用模拟器:

adb shell sqlite3 --version   

UPDATE: Since SDK 29 (emulator revision 8), the adb shell command gives:

更新:从 SDK 29(模拟器修订版 8)开始,adb shell 命令给出:

/system/bin/sh: sqlite3: inaccessible or not found

Any ideas why? Issue tracker here.

任何想法为什么?问题跟踪器在这里

SQLite 3.28.0(window functions!):

SQLite 3.28.0窗口函数!):

  • 30-11.0-R (Revision 2 in SDK Manager)
  • 30-11.0-R(SDK 管理器中的修订版 2)

SQLite 3.22.0:

SQLite 3.22.0

  • 29-10.0-Q (Revision 8 in SDK Manager)
  • 28-9.0-P
  • 29-10.0-Q(SDK 管理器中的修订版 8)
  • 28-9.0-P

SQLite 3.19.4(for some reason 3.19.4 does not exist in sqlite release notes! so linking to version control check-ins instead):

SQLite 3.19.4(由于某种原因,sqlite 发行说明中不存在 3.19.4!因此链接到版本控制签入):

  • 27-8.1.0-O MR1
  • 27-8.1.0-O MR1

SQLite 3.18.2:

SQLite 3.18.2

  • 26-8.0.0-O (note: O beta versions used 3.18.0)
  • 26-8.0.0-O(注意:O beta 版本使用3.18.0

SQLite 3.9.2:

SQLite 3.9.2

  • 25-7.1.1-N MR1
  • 24-7.0-N (note: previews used the same version)
  • 25-7.1.1-N MR1
  • 24-7.0-N(注意:预览使用相同版本)

SQLite 3.8.10.2:

SQLite 3.8.10.2

  • 23-6.0-M (note: M Preview 1 (SDK level 22) used 3.8.10)
  • 23-6.0-M (注:M Preview 1 (SDK level 22) used 3.8.10)

SQLite 3.8.6.1(SQLite link is for 3.8.6 because 3.8.6.1 does not exist for some reason):

SQLite 3.8.6.1(SQLite 链接适用于 3.8.6,因为 3.8.6.1 由于某种原因不存在):

  • 22-5.1.1-Lollipop
  • 22-5.1.1-棒棒糖

SQLite 3.8.6:

SQLite 3.8.6

  • 21-5.0-Lollipop
  • 21-5.0-棒棒糖

SQLite (unknown):

SQLite(未知):

  • 20-4.4W.2-Android Wear (no emulator available, but probably either 3.7.11 or 3.8.4.3)
  • 20-4.4W.2-Android Wear(没有可用的模拟器,但可能是 3.7.11 或 3.8.4.3)

SQLite 3.7.11:

SQLite 3.7.11

  • 19-4.4-KitKat
  • 18-4.3-Jelly Bean
  • 17-4.2-Jelly Bean
  • 16-4.1-Jelly Bean (broken link, see here)
  • 19-4.4-奇巧
  • 18-4.3-果冻豆
  • 17-4.2-果冻豆
  • 16-4.1-Jelly Bean(断开的链接,请参阅此处

SQLite 3.7.4:

SQLite 3.7.4

  • 15-4.0.3-Ice Cream Sandwich
  • 14-4.0-Ice Cream Sandwich (broken link, see here)
  • 13-3.2-Honeycomb
  • 12-3.1-Honeycomb
  • 11-3.0-Honeycomb (broken link, see here)
  • 15-4.0.3-冰淇淋三明治
  • 14-4.0-冰淇淋三明治(断开的链接,见这里
  • 13-3.2-蜂窝
  • 12-3.1-蜂窝
  • 11-3.0-Honeycomb(断开的链接,请参阅此处

SQLite 3.6.22:

SQLite 3.6.22

  • 10-2.3.3-Gingerbread
  • 9-2.3.1-Gingerbread
  • 8-2.2-Froyo (broken link, see here)
  • 10-2.3.3-姜饼
  • 9-2.3.1-姜饼
  • 8-2.2-Froyo(断开的链接,见这里

SQLite 3.5.9:

SQLite 3.5.9

  • 7-2.1-Eclair
  • 4-1.6-Donut
  • 3-1.5-Cupcake (broken link, see here)
  • 7-2.1-泡芙
  • 4-1.6-甜甜圈
  • 3-1.5-Cupcake(断开的链接,请参阅此处

Note: Android SDK level links show where the android.database.sqlitepackage has changed. Where there is no link (e.g. SDK level 17), indicates no changes to that package.

注意:Android SDK 级别的链接显示了android.database.sqlite包的更改位置。如果没有链接(例如 SDK 级别 17),则表示该包没有更改。

Note: Here are some anomalies (list by no means exhaustive):

注意:以下是一些异常情况(列表并非详尽无遗):

SQLite 3.7.13(instead of 3.7.11):

SQLite 3.7.13(而不是 3.7.11):

  • LG Optimus L70 MS323 LGMS323|KOT49I.MS32310b (19-4.4-KitKat)
  • LG Optimus G E975 LG-E975|JZO54K (16-4.1-Jelly Bean)
  • LG G2 D802 LG-D802|JDQ39B (17-4.2-Jelly Bean)
  • LG 擎天柱 L70 MS323 LGMS323|KOT49I.MS32310b (19-4.4-KitKat)
  • LG 擎天柱 G E975 LG-E975|JZO54K (16-4.1-果冻豆)
  • LG G2 D802 LG-D802|JDQ39B (17-4.2-果冻豆)

SQLite 3.7.6.3(instead of 3.6.22):

SQLite 3.7.6.3(而不是 3.6.22):

  • LG Optimus Sol E730/myTouch E739/myTouch Q C800 (10-2.3.3-Gingerbread, GRJ22)
  • LG Optimus Vu F100S/F100L (10-2.3.3-Gingerbread, RK39F)
  • LG Optimus LTE TAG F120K/F120L (10-2.3.3-Gingerbread, GRK39F)
  • LG Optimus LTE L-01D (10-2.3.3-Gingerbread, GRJ90)
  • LG Optimus Net P690b (10-2.3.3-Gingerbread, GINGERBREAD)
  • LG Prada KU5400 (10-2.3.3-Gingerbread, GWK74)
  • LG Prada P940 (10-2.3.3-Gingerbread, GWK74)
  • LG LU6200/SU640 (10-2.3.3-Gingerbread, GRJ90)s
  • LG Optimus Sol E730/myTouch E739/myTouch Q C800(10-2.3.3-姜饼,GRJ22)
  • LG 擎天柱 F100S/F100L(10-2.3.3-姜饼,RK39F)
  • LG Optimus LTE TAG F120K/F120L(10-2.3.3-姜饼,GRK39F)
  • LG Optimus LTE L-01D(10-2.3.3-姜饼,GRJ90)
  • LG Optimus Net P690b(10-2.3.3-姜饼、姜饼)
  • LG Prada KU5400(10-2.3.3-姜饼,GWK74)
  • LG Prada P940(10-2.3.3-姜饼,GWK74)
  • LG LU6200/SU640 (10-2.3.3-Gingerbread, GRJ90)s

SQLite 3.7.5(instead of 3.7.4):

SQLite 3.7.5(而不是 3.7.4):

  • Samsung Galaxy Note (15-GT-N7000|IML74K.ZSLPF)
  • Samsung Galaxy SII (15-SC-02C|IML74K.OMMP4 and GT-I9100|IML74K.DXLP7)
  • Samsung Galaxy S Duos (15-GT-S7562|IMM76I.S7562XXBMD6)
  • Samsung Galaxy Tab 7.7 (15-GT-P6810|IMM76D.ZSLP8)
  • 三星 Galaxy Note (15-GT-N7000|IML74K.ZSLPF)
  • 三星 Galaxy SII(15-SC-02C|IML74K.OMMP4 和 GT-I9100|IML74K.DXLP7)
  • 三星 Galaxy S Duos (15-GT-S7562|IMM76I.S7562XXBMD6)
  • 三星 Galaxy Tab 7.7 (15-GT-P6810|IMM76D.ZSLP8)

SQLite 3.7.0.1(instead of 3.6.22):

SQLite 3.7.0.1(而不是 3.6.22):

  • LG Esteem MS910 (10-2.3.3-Gingerbread, GSE-_v.05)
  • AndroTab (8-2.2-Froyo, 1.0.7100.0385)
  • GPLUS MUSN M500 (8-2.2-Froyo, FRG83G)
  • LG Esteem MS910(10-2.3.3-姜饼,GSE-_v.05)
  • AndroTab (8-2.2-Froyo, 1.0.7100.0385)
  • GPLUS MUSN M500 (8-2.2-Froyo, FRG83G)

SQLite 3.6.23.1(instead of 3.5.9):

SQLite 3.6.23.1(而不是 3.5.9):

  • Motorola Backflip MB300 (7-2.1-Eclair, ERD79)
  • Garmin-Asus nüvifone A10/A50/Garminfone (7-2.1-Eclair, ERE27)
  • 摩托罗拉 Backflip MB300(7-2.1-Eclair,ERD79)
  • Garmin-Asus nüvifone A10/A50/Garminfone (7-2.1-Eclair, ERE27)

Note: adb command to get SQLite version only works on emulators and on devices with sqlite3 available: https://stackoverflow.com/a/3645800/444761

注意:获取 SQLite 版本的 adb 命令仅适用于模拟器和提供 sqlite3 的设备:https: //stackoverflow.com/a/3645800/444761

For other devices, see Juri's answer.

对于其他设备,请参阅Juri 的回答

I have added an Issue #58909to the Android Issue Tracker. Please star this if you would like to support it.

我已将问题 #58909添加到 Android 问题跟踪器。如果你想支持它,请给它加星号。

Note: if you want your app to use the same version of SQLite across all Android versions, consider using this 3rd party SQLite support library.

注意:如果您希望您的应用在所有 Android 版本中使用相同版本的 SQLite,请考虑使用此 3rd 方 SQLite 支持库

回答by Juri

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:

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

Cursor cursor = SQLiteDatabase.openOrCreateDatabase(":memory:", 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.

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

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

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

回答by yanchenko

$ adb shell
$ sqlite3 --version
sqlite3 --version
3.5.9

Same on ADP1 1.6 & 2.1 emulator.

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

回答by Petterson

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

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

enter image description here

在此处输入图片说明

The overview is from the link in Mark Carters answer.

概述来自 Mark Carters 回答中的链接。

回答by Roar Gr?nmo

In Room you can query

在房间你可以查询

SELECT sqlite_version()

选择 sqlite_version()

RG

RG