Reputation: 2150
Let's say I'm pushing a new version app to google play (17 to 18).
Is there a chance some devices have SharedPreference wiped out ? How about the local database ?
I think it could happen if some device somehow where to uninstall reinstall the app automatically rather than update.
Note : I've actually seen SharedPreferences getting wiped out on a few devices after update. Which is why I wonder why, how and it can happen to the Database as well.
Upvotes: 1
Views: 85
Reputation: 777
in your SQLiteOpenHelper
@Override
public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
if (oldVersion < newVersion) {
final Cursor cursor = db.rawQuery("select name from sqlite_master", null);
if (cursor != null) {
while (cursor.moveToNext()) {
db.execSQL("delete from " + cursor.getString(0));
}
cursor.close();
}
}
}
Upvotes: 1