Skip to content Skip to sidebar Skip to footer

Error - Android.database.cursorindexoutofboundsexception: Index 0 Requested, With A Size Of 0

I'm triying to do a database, but i have a problem... This is the log: E/AndroidRuntime(894): FATAL EXCEPTION: main E/AndroidRuntime(894): java.lang.IllegalStateException: Could

Solution 1:

In fetchItemByType check if cursor.moveToFirst() returns true if not then you dont have any data and you can return -1. I think CursorIndexOutOfBoundsException is not getting caught in your program and 0 is getting returned from the fetchItemByType function.


Solution 2:

if (cursor!= null && cursor.moveToFirst()){
    while (!cursor.isAfterLast()) {
                        str = String.valueOf(cursor.getInt(1));

                        arrayList.add(str);
                        cursor.moveToNext();
                    }
                    cursor.close();
    }

Post a Comment for "Error - Android.database.cursorindexoutofboundsexception: Index 0 Requested, With A Size Of 0"