Android中使用的SQLite版本?

Android使用的SQLite版本是什么?

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

107157 次浏览
$ adb shell sqlite3 --version
3.5.9

ADP1 1.6 &也是如此;2.1模拟器。

虽然文档给出了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版本的快速代码。例如,在HTC Hero和Android 2.1上,我得到:3.5.9

在我的Nexus One和Android 2.2上,我甚至得到3.6.22

这里有一个官方文档的链接,其中包括这个答案的要点:Android.database.sqlite包级javadoc

Kotlin代码获得框架SQLite版本(提示:只需在活动onCreate()中插入断点,并在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) }

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

< span style=" font - family:宋体;">API级别* . >API级别 < span style=" font - family:宋体;"> < / th >版本 < span style=" font - family:宋体;"> < / th >名称 < span style=" font - family:宋体;">SQLite < span style=" font - family:宋体;">33 < span style=" font - family:宋体;"13 > < / td > < span style=" font - family:宋体;"道明> > T < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_32_2.html " rel = " noreferrer " > 3.32.2 < / > < / td > < span style=" font - family:宋体;"> 32道明> < / < span style=" font - family:宋体;"> 12 l < / td > < span style=" font - family:宋体;"> Sv2 td > < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_32_2.html " rel = " noreferrer " > 3.32.2 < / > < / td > < span style=" font - family:宋体;"> 31道明> < / < span style=" font - family:宋体;"> 12道明> < / < span style=" font - family:宋体;"道明> > S < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_32_2.html " rel = " noreferrer " > 3.32.2 < / > < / td > < span style=" font - family:宋体;">30 < span style=" font - family:宋体;"11道明> < / > < span style=" font - family:宋体;"道明> > R < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_28_0.html " rel = " noreferrer " > 3.28.0 < / > < / td > < span style=" font - family:宋体;">29 < span style=" font - family:宋体;"10 > < / td > < span style=" font - family:宋体;"道明> > Q < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_22_0.html " rel = " noreferrer " > 3.22.0 < / > < / td > < span style=" font - family:宋体;">28 < span style=" font - family:宋体;"9 > < / td > < span style=" font - family:宋体;">派道明> < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_22_0.html " rel = " noreferrer " > 3.22.0 < / > < / td > < span style=" font - family:宋体;">27 < font - family:宋体 . font - family:宋体; < span style=" font - family:宋体;">奥利奥道明> < / . < span style=" font - family:宋体;"> 26道明> < / < span style=" font - family:宋体;"25道明> < / > < span style=" font - family:宋体; < span style=" font - family:宋体;"道明> >牛轧糖< / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_9_2.html " rel = " noreferrer " > 3.9.2 < / > < / td > < span style=" font - family:宋体;">24 < span style=" font - family:宋体;"道明> >牛轧糖< / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_9_2.html " rel = " noreferrer " > 3.9.2 < / > < / td > < span style=" font - family:宋体;"23 > < / td > < span style=" font - family:宋体;"> 22道明> < / < font - family:宋体 . font - family:宋体; < span style=" font - family:宋体;"道明> >棒棒糖< / . < span style=" font - family:宋体;"21道明> < / > < span style=" font - family:宋体;"> 20道明> < / 4. .2 < / td > < span style=" font - family:宋体;"未知> < / td > < span style=" font - family:宋体;"19 > < / td > 4. . " font - family:宋体; < span style=" font - family:宋体;"> KitKat td > < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_11.html " rel = " noreferrer " > 3.7.11 < / > < / td > < span style=" font - family:宋体;"> 18道明> < / . " font - family:宋体; < span style=" font - family:宋体;"道明> >软心豆粒糖< / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_11.html " rel = " noreferrer " > 3.7.11 < / > < / td > < span style=" font - family:宋体;"> 17道明> < / . " font - family:宋体; < span style=" font - family:宋体;"道明> >软心豆粒糖< / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_11.html " rel = " noreferrer " > 3.7.11 < / > < / td > < span style=" font - family:宋体;">16** < font - family:宋体 . font - family:宋体; < span style=" font - family:宋体;"道明> >软心豆粒糖< / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_11.html " rel = " noreferrer " > 3.7.11 < / > < / td > < span style=" font - family:宋体;"> 15道明> < / . < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_4.html " rel = " noreferrer " > 3.7.4 < / > < / td > < span style=" font - family:宋体;">14** . < span style=" font - family:宋体;">冰淇淋三明治 < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_4.html " rel = " noreferrer " > 3.7.4 < / > < / td > < span style=" font - family:宋体;"13 > < / td > 3. . < d style="text-align: center; < span style=" font - family:宋体;"蜂巢> < / td > < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_4.html " rel = " noreferrer " > 3.7.4 < / > < / td > < span style=" font - family:宋体;"> 12道明> < / < font style=" font - family:宋体; < span style=" font - family:宋体;"蜂巢> < / td > < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_4.html " rel = " noreferrer " > 3.7.4 < / > < / td > < span style=" font - family:宋体;">11** . < span style=" font - family:宋体;"蜂巢> < / td > < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_7_4.html " rel = " noreferrer " > 3.7.4 < / > < / td > < span style=" font - family:宋体;"10 > < / td > 2. . . < span style=" font - family:宋体;"姜饼> < / td > < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_6_22.html " rel = " noreferrer " > 3.6.22 < / > < / td > < span style=" font - family:宋体;"9 > < / td > < font style=" font - family:宋体; < span style=" font - family:宋体;"姜饼> < / td > < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_6_22.html " rel = " noreferrer " > 3.6.22 < / > < / td > < span style=" font - family:宋体;">8** < font style=" font - family:宋体; < span style=" font - family:宋体;"> Froyo td > < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_6_22.html " rel = " noreferrer " > 3.6.22 < / > < / td > < span style=" font - family:宋体;"7 > < / td > < font style=" font - family:宋体; < span style=" font - family:宋体;"> < / td >朵 < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_5_9.html " rel = " noreferrer " > 3.5.9 < / > < / td > < span style=" font - family:宋体;"4 > < / td > < span style=" font - family:宋体; < span style=" font - family:宋体;">甜甜圈道明> < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_5_9.html " rel = " noreferrer " > 3.5.9 < / > < / td > < span style=" font - family:宋体;">3** < font style=" font - family:宋体; < span style=" font - family:宋体;">蛋糕道明> < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_5_9.html " rel = " noreferrer " > 3.5.9 < / > < / td >
笔记
窗口函数
3.19.3和版本控制签入,因为3.19.4链接不存在
奥利奥道明> < / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_18_2.html " rel = " noreferrer " > 3.18.2 < / > < / td > O beta版本使用3.18.0
7.0
< / td > < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_8_10_2.html " rel = " noreferrer " > 3.8.10.2 < / > < / td > M预览1 (SDK级别22)使用3.8.10
3.8.6和版本控制签入,因为3.8.6.1链接不存在
>棒棒糖< / < span style=" font - family:宋体;"> < a href = " https://www.sqlite.org/releaselog/3_8_6.html " rel = " noreferrer " > 3.8.6 < / > < / td >
没有可用的模拟器,但可能是3.7.11或3.8.4.3
冰淇淋三明治
4.0
3.0

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

**破碎的SDK链接,见在这里

注意:如果你想让你的应用在所有Android版本上使用相同版本的SQLite,可以考虑使用Requery的第三方SQLite支持库SQLCipher(如果你还想加密)。

android api和支持的SQLite版本的简短概述。

enter image description here

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

在房间里你可以查询

选择sqlite_version ()

RG