Home » Android » database – Version of SQLite used in Android?

database – Version of SQLite used in Android?

Posted by: admin March 10, 2020 Leave a comment

Questions:

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 command which would save me having to copy data, drop the table, recreate table and re-insert data.

How to&Answers:

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? See: https://issuetracker.google.com/issues/142003176

UPDATE: Sorry, older (SDK 18 and earlier) package-level API diffs have stopped working: https://issuetracker.google.com/issues/37048579

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 (note: previews used the same version)

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

SQLite 3.7.4:

  • 15-4.0.3-Ice Cream Sandwich
  • 14-4.0-Ice Cream Sandwich
  • 13-3.2-Honeycomb
  • 12-3.1-Honeycomb
  • 11-3.0-Honeycomb

SQLite 3.6.22:

  • 10-2.3.3-Gingerbread
  • 9-2.3.1-Gingerbread
  • 8-2.2-Froyo

SQLite 3.5.9:

  • 7-2.1-Eclair
  • 4-1.6-Donut
  • 3-1.5-Cupcake

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: Here are some anomalies (list by no means exhaustive):

SQLite 3.7.13 (instead of 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)

SQLite 3.7.6.3 (instead of 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

SQLite 3.7.5 (instead of 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)

SQLite 3.7.0.1 (instead of 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)

SQLite 3.6.23.1 (instead of 3.5.9):

  • Motorola 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

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.

Answer:

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.

Answer:

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

Same on ADP1 1.6 & 2.1 emulator.

Answer:

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

enter image description here

The overview is from the link in Mark Carters answer.