I'm trying to upgrade my DB and everything is good, but the user_version won't upgrade, but every time I start the application. it would go to onUpgrade and perform this upgrading stuff again and again.
There is a similar question here onUpgrade database Android version number not increasing, but he haven't found any answer so I decided to ask once more, how to increment and save the db version?
I tried with setVersion
, with PRAGMA
, setting it outside the onUpgrade() and inside and everything that I could imagine, but it won't increment itself, my Database is 14MiB, so I can't afford to copy one more to assets as done the TS in the question above.
Here is my code for onUpgrade(), I'm exporting here the data of previous DB to XML, dropping the tables, creating new ones and importing data from the xml to new tables.
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion == 1) {
cImportExport cImpExp = new cImportExport(db, cbActivity.MY_FILES_DIR + File.separator + "export.xml", oldVersion);
cImpExp.Export();
db.execSQL("DROP TABLE IF EXISTS " + "1");
db.execSQL("DROP TABLE IF EXISTS " + "2");
onCreate(db);
cImpExp.Import();
}
}
Aucun commentaire:
Enregistrer un commentaire