my app experiences a crash when the sqlite database is updated the first time. Reloading the app, it works fine from then on. I\'m guessing this has to do with the onUpgrade
You don't need to delete the database, just copy over it using the method you've alady defined (copyDataBase
), like this:
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Toast.makeText(myContext, "onUpgrade called!", Toast.LENGTH_LONG).show();
if (oldVersion < newVersion) {
Log.v("Database Upgrade", "Database version higher, upgrading");
try {
copyDataBase();
} catch (IOException e) {
throw new Error("Error upgrading database");
}
}
}