Version of SQLite used in Android?

后端 未结 5 1583
悲哀的现实
悲哀的现实 2020-11-21 22:55

What is the version of SQLite used in Android?

Reason: I\'m wondering how to handle schema migrations. The newer SQLite versions support an \"ALTER TABLE\" SQL comma

相关标签:
5条回答
  • 2020-11-21 23:19
    $ adb shell
    $ sqlite3 --version
    sqlite3 --version
    3.5.9
    

    Same on ADP1 1.6 & 2.1 emulator.

    0 讨论(0)
  • 2020-11-21 23:20

    In Room you can query

    SELECT sqlite_version()

    RG

    0 讨论(0)
  • 2020-11-21 23:22

    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

    Using the emulators:

    adb shell sqlite3 --version   
    

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

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

    Any ideas why? Issue tracker here.

    SQLite 3.28.0 (window functions!):

    • 30-11.0-R (Revision 7 in SDK Manager)

    SQLite 3.22.0:

    • 29-10.0-Q (Revision 8 in SDK Manager)
    • 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):

    • 27-8.1.0-O MR1

    SQLite 3.18.2:

    • 26-8.0.0-O (note: O beta versions used 3.18.0)

    SQLite 3.9.2:

    • 25-7.1.1-N MR1
    • 24-7.0-N

    SQLite 3.8.10.2:

    • 23-6.0-M (note: 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):

    • 22-5.1.1-Lollipop

    SQLite 3.8.6:

    • 21-5.0-Lollipop

    SQLite (unknown):

    • 20-4.4W.2-Android Wear (no emulator available, but probably either 3.7.11 or 3.8.4.3)

    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)

    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)

    SQLite 3.6.22:

    • 10-2.3.3-Gingerbread
    • 9-2.3.1-Gingerbread
    • 8-2.2-Froyo (broken link, see here)

    SQLite 3.5.9:

    • 7-2.1-Eclair
    • 4-1.6-Donut
    • 3-1.5-Cupcake (broken link, see here)

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

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

    For other devices, see Juri's answer.

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

    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.

    0 讨论(0)
  • 2020-11-21 23:28

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

    The overview is from the link in Mark Carters answer.

    0 讨论(0)
  • 2020-11-21 23:37

    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.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.

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

    0 讨论(0)
提交回复
热议问题