SQLite
 SQL >> Datenbank >  >> RDS >> SQLite

SQLiteException „no such table“ nach App-Update

Die Ursache: Auf manchen Geräten wird Ihre App aktualisiert, wodurch checkDataBase() true zurückgibt und copyDataBase() nicht mehr aufgerufen wird. Die App nutzt weiter die alte Datenbank – ohne die Tabelle generalSettings.

Abhilfe schafft eine Aktualisierung in onUpgrade:

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    if (newVersion > oldVersion) {
        copyDatabase();
    }
} 

Und im Konstruktor die Versionsnummer konsequent erhöhen:

public InstallDB(Context context, String name) {
    super(context, name, null, DB_VERSION); // bei jedem Build erhöhen
    this.ctx = context;
    this.DBNAME = name;
    this.DBPATH = this.ctx.getDatabasePath(DBNAME).getAbsolutePath();
    Log.e("Path 1", DBPATH);
}