delete sqlite database when updating new version of application
android, android-sqlite, database, sqlite
Solution
Finally done with simple solution:
/** UPGRADE DATABASE **/
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.i(TAG, "Database Version: OLD: "+ oldVersion + " = NEW: "+newVersion);
if(context.deleteDatabase(DATABASE_NAME))
Log.i(TAG, "Database Deleted....");
else
Log.i(TAG, "Database Not Deleted..");
}
Problem
I have uploaded an apk (version 1.0) with 22 tables in SQLite Database on Google Playstore. Now i want to update database with 36 tables in new version (version 2.0) of application. I am storing `datebase` at default location so when i press "Clear data" in Application Manager, database is gonna deleted. I just want to know how to delete old database (same as clear data) when user update new version? Update: If is there any solution for clear data while updating application from play store then also answered me. Your help would be appreciated. Thanks.