开发者

what version of sqlite i should use, if i target android 2.2

Currently I am using Sqlite 2.0 because the book I am using to learn uses Sqlite 2.0. But now I find other new versions. So is th开发者_如何学Goere any mapping like android 2.2 should use this version kind of a thing.

private static final int DATABASE_VERSION = 2;
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
    + newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE *");
onCreate(db);
}
}

Above is the code i found in a study material, where it tells the DB version as 2. may i know what that version is denoting to, as @gregory link tells android starts with SQLite version 3.4.

I would like to know when this upgrade method comes into place or when it should be used

Thanks


The documentation states that you can use version 3.4.0 :

Android ships with SQLite version 3.4.0

Apparently that's a minimum version, and some devices actually use an updated version of SQLite. Some people listed SQLite versions they encountered in another question : Version of SQLite used in Android?

edit : that version number is just a hardcoded number for YOUR database. When you decide to update your database to include new tables/columns/whatever, you can increment that database number, and then when Android loads your database that method gets called to update it if needed (comparing the old stored database version to the new one).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜