In the last time I get some strange reviews on the PlayStore.
Whyever after installing the update of my app, users complain all their app data has been wiped. I have absolutely no idea how this can happen. Database is only recreated if tables do not exist.
Code which is executed after opening database connection:
private void createTablesIfNotExist() {
//query tables
Cursor c = DatabaseManager.executeSelect("SELECT name FROM sqlite_master WHERE type = \"table\"");
//if tables already created, do nothing (+1 because of header table)
if (!((tableAmount + 1) == c.getCount())) {
//meta data table
this.database.execSQL("DROP TABLE IF EXISTS android_metadata;");
this.database.execSQL("CREATE TABLE android_metadata (locale TEXT);");
this.database.execSQL("INSERT INTO android_metadata VALUES('de_DE');");
}
//create event table
c = DatabaseManager.executeSelect("SELECT name FROM sqlite_master WHERE name = \"" + EVENTS + "\"");
c.moveToFirst();
if(c.isAfterLast()) {
this.database.execSQL("CREATE TABLE.....");
}
c = DatabaseManager.executeSelect("SELECT name FROM sqlite_master WHERE name = \"" + ASSIGNED_PRODUCTS + "\"");
c.moveToFirst();
if(c.isAfterLast()) {
this.database.execSQL("CREATE TABLE.......");
}
}
Has anyone an idea? Thanks :)