I released an update of my app and am getting a ton of errors from users and I can\'t recreate it or pin-point the problem.
Two errors I\'m getting:
java.lang.
I could not recreate issue because in testing, I was upgrading from DB version 3 to version 4. Many of my users were upgrading from version 2 to version 4. Some of the code for upgrading from 2 to 3 was method-based. I ended up changing some of those methods for version 4, which broke the version 3 upgrade. I then was getting a caught exception from a cursorToObject() method I had, which caused the database.close to be skipped and then I got the sqlite exception
I have faced the same issue in one of my app, and how i solved that issue is through removing the cursor.close(). Hope it will help :)
Obviously we need to see the on-upgrade method seems to be the root cause of your issue. I use the Adams Upgrade method I named it for the blog I found it oun.
note: Each upgrade is done in the upgradeTo <= newVersion loop. Maybe someday I'll put a progress bar on this loop.
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
int upgradeTo = oldVersion + 1;
while (upgradeTo <= newVersion) {
switch (upgradeTo) {
// update old resrawid's to constants
// this was caused when I saved R values in the database
// and then later realized they would change.
// the old resrawid is changed to a constant.
case 42:
ContentValues values;
@SuppressWarnings("unused")
// used for debugging so I can see the value of the update.
int res;
int rs;
rs = 2130968576;
values = new ContentValues();
values.put(
KEY_RESRAWID,
com.gosylvester.bestrides.ImageTextListViewActivity.SAMPLE_DRAGON);
res = db.update(TABLE_RIDES, values, KEY_RESRAWID + " = ?",
new String[] { String.valueOf(rs) });
rs = 2130968577;
values = new ContentValues();
values.put(
KEY_RESRAWID,
com.gosylvester.bestrides.ImageTextListViewActivity.SAMPLE_M119);
res = db.update(TABLE_RIDES, values, KEY_RESRAWID + " = ?",
new String[] { String.valueOf(rs) });
rs = 2130968578;
values = new ContentValues();
values.put(
KEY_RESRAWID,
com.gosylvester.bestrides.ImageTextListViewActivity.SAMPLE_MEDINA);
res = db.update(TABLE_RIDES, values, KEY_RESRAWID + " = ?",
new String[] { String.valueOf(rs) });
break;
case 43:
// new column added for last_viewed.
db.execSQL(VERSION_43_ALTER);
break;
case 44:
// new index on KEY_DATE_UPDATE DESC
db.execSQL(VERSION_44_CREATE_INDEX);
}
upgradeTo++;
}
}
Good Luck Danny117