I'm facing some issue with app uninstall from the device. The related database seems to not being deleted so I'm unable to update my table and add new column. What can be the problem.
Android version is 6.0.
I'm facing some issue with app uninstall from the device. The related database seems to not being deleted so I'm unable to update my table and add new column. What can be the problem.
Android version is 6.0.
To remove the database when the app uninstall in android6... Adds in the AndroidManifest the follow tags:
<application
android:allowBackup="false"
tools:replace="android:allowBackup">
If you want any update reflects in ur existing database , then no need to delete or drop it manually . sqlite provides onUpgrade() for that . you can find lots of good stackoverflow solution ,just google on it how onUpgrade() used .
you can use that like this way ,
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
switch(oldVersion){
case 1:
db.execSQL("ALTER TABLE " + DATABASE_TABLE + " ADD COLUMN " + NEW_COLUMN_NAME + TYPE);
}
}
Uninstalling only removes the files in data/data/YOUR_PACKAGE
.
If you are adding .db
object by your own, (so do not implement Content Provider
) and put the db object another directory it wont be deleted.
Also you can use onUpgrade()
method.