In my application I have a databse upgrade scenario and onUpdate(…) i am doing as below,
db.execSQL("BEGIN TRANSACTION;"); db.execSQL("DROP TABLE " + TABLE_CONT + ";"); // drop old table db.execSQL("CREATE TABLE "+ TABLE_CONT ... // create a new and add few more columns db.execSQL("INSERT INTO "..// insert data as per new table schema db.execSQL("COMMIT;");
After upgrade my application is trying to fetch data from the table,
final SQLiteDatabase sqliteDatabase= mDatabaseHelper.getReadableDatabase(); final Cursor cursor = sqliteDatabase.rawQuery("SELECT * FROM " +TABLE_CONT);
But cursor retruns the old table schema which is already dropped in onUpdate. After closing the application and restarting the application, it gives data as per new schema.
Am I doing anything wrong here?