As you might already know, Android comes with a preinstalled SQLite database. This is quite handy because you can rely on it without the need to care about installing a DB along with your application (although you can, standalone, small DB's of course like HSQLDB). On the Android Developer
documentation SQLite version 3.4.0 is indicated as the reference version to develop against. Usually you should be fine with that and if you don't have any valid reason you should stay with. But still in the very rare cases you may have the need to detect the installed version on the handset your application is running on (maybe simplifying/optimizing a complex query with operators introduced in some 3.4+ version).
So you have two different possibilities for doing so. If you have the device at hand and want to know the version, you can simply plug the USB cable and connect through the adb bridge typing
(Alex, Stackoverflow)$ adb shell
$ sqlite3 --version
Alternatively the following code determines the version at runtime:
Cursor cursor = SQLiteDatabase.openOrCreateDatabase(":memory:", null).rawQuery("select sqlite_version() AS sqlite_version", null);
String sqliteVersion = "";
while(cursor.moveToNext()){
sqliteVersion += cursor.getString(0);
}
Interestingly, several comments of other users o
n my Stackoverflow post revealed that there are substantially higher SQLite versions available on the devices as 3.4.0.
Questions? Thoughts? Hit me up
on Twitter