views:

518

answers:

3

Reason: Im 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.

+5  A: 

3.4.0

jqpubliq
For all API levels?
Eno
It's on the documentation, but it seems like they forgot to update it. The real version installed is much higher (see my post below on how to verify that)
Juri
+3  A: 
$ adb shell
$ sqlite3 --version
sqlite3 --version
3.5.9

Same on ADP1 1.6 & 2.1 emulator.

alex
+2  A: 

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.

Juri
I imagine 3.4.0 is given as a minimum version # - for portability you probably shouldn't assume its a higher version unless you have a really good reason to do so.
Eno
sure, you're right. But if you have to use some advanced features which may improve performance on higher SQLite versions, you may use the code to query and eventually switch the kind of query depending on the deployed version :)
Juri