Skip to content Skip to sidebar Skip to footer

Sqlitedatabase Error, Unhelpful Log

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.IllegalStateException:

Solution 1:

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 :)

Solution 2:

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

Solution 3:

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
publicvoid 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.case42:
            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 + " = ?",
                    newString[] { 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 + " = ?",
                    newString[] { 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 + " = ?",
                    newString[] { String.valueOf(rs) });
            break;
        case43:
            // new column added for last_viewed.
            db.execSQL(VERSION_43_ALTER);
            break;

        case44:
            // new index on KEY_DATE_UPDATE DESC
            db.execSQL(VERSION_44_CREATE_INDEX);
        }
        upgradeTo++;
    }
}

Good Luck Danny117

Post a Comment for "Sqlitedatabase Error, Unhelpful Log"