1

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

Ajax3.14
  • 1,647
  • 5
  • 24
  • 42

1 Answers1

1

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

Community
  • 1
  • 1
Gregory
  • 4,384
  • 1
  • 25
  • 21
  • Thanks @Gregory the links are useful and I edited the question and added few more info because now my question is if 3.4 is the starting version for android then what is 2.0 given in the code. hope i would get some help. anyways thanks – Ajax3.14 Jul 05 '11 at 14:56
  • @ajax3-14 updated with the explanation. That's not 2.0, it's a local database number you give to YOUR database, it has nothing to do with the SQL version. The same way your app has a version number (1.0.0 at first) and Android has a different one (like 2.3.4). – Gregory Jul 05 '11 at 17:40