Skip to content Skip to sidebar Skip to footer

My App Is Working On Emulator, Not On Device. Log Cat Says Android.database.cursorindexoutofboundsexception

I am unable to find where on the database i have made a mistake. The app that i am making works on the emulator the emulator, but now that i am trying to run it on mobile device on

Solution 1:

Always use this condition when dealing with cursors:

if( cursor != null && cursor.moveToFirst() ) {
//do operations with records
}

Check whether the cursor is null or not. If it not null, then move the cursor to the first record. The cursor here is probably null (has no records).

Solution 2:

Check the return value from moveToFirst(), before you try to read anything from the cursor. It looks as if no results are being returned.

if (cursor.moveToFirst()) {
//do your effort
}

Post a Comment for "My App Is Working On Emulator, Not On Device. Log Cat Says Android.database.cursorindexoutofboundsexception"