I Am Getting Error While Version Creating My Database
I am getting following error while Version Creating My Database. 01-18 12:08:01.157: ERROR/AndroidRuntime(3079): Caused by: java.lang.IllegalArgumentException: Version must be >
Solution 1:
Each database you create has a version number. That way you can keep track of them if you upgrade the application (perform necessary database changes for the upgrade on existing data). The version number must start from 1.
If you look at the following code:
privatestaticclassOpenHelperextendsSQLiteOpenHelper{
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
publicvoid onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + "
(id INTEGER PRIMARY KEY, name TEXT)");
}
@Override
publicvoid onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("Example", "Upgrading database, this will drop tables and recreate.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
onUpgrade
will handle all necessary database upgrades. Sometimes you'll opt to just destroy (drop) the current database and create a new one.
Solution 2:
it seems you have set previous version as 0, remove your app from phone, reinstall it, make sure new version is greater then previous one.
Post a Comment for "I Am Getting Error While Version Creating My Database"