This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Android and the fly likes android CursorIndexOutOfBoundsException: Index 20 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Mobile » Android
Reply Bookmark "android CursorIndexOutOfBoundsException: Index 20" Watch "android CursorIndexOutOfBoundsException: Index 20" New topic
Author

android CursorIndexOutOfBoundsException: Index 20

Alexander Brown
Greenhorn

Joined: Sep 28, 2012
Posts: 1
I am having problems with my cursor for some reason it is producing the CursorIndexOutOfBoundException.
The error occurs on record 19 according to my counter variable. I belive the problem is occuring within these two method. I set the cursor to move to the first record which appears to work.
Although when I try and fetch the current position it returns a negative one. This is the method I used c.getPosition().





Here is my logcat

09-28 16:23:22.134: E/AndroidRuntime(530): FATAL EXCEPTION: main
09-28 16:23:22.134: E/AndroidRuntime(530): android.database.CursorIndexOutOfBoundsException: Index 20 requested, with a size of 20
09-28 16:23:22.134: E/AndroidRuntime(530): at android.database.AbstractCursor.checkPosition(AbstractCursor.java:400)
09-28 16:23:22.134: E/AndroidRuntime(530): at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
09-28 16:23:22.134: E/AndroidRuntime(530): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
09-28 16:23:22.134: E/AndroidRuntime(530): at alex.android.development.Basic_database_questionsActivity.DisplayRadioButton(Basic_database_questionsActivity.java:374)
09-28 16:23:22.134: E/AndroidRuntime(530): at alex.android.development.Basic_database_questionsActivity.nextRecord(Basic_database_questionsActivity.java:144)



Here is the main body of the code

Przemek Boryka
Ranch Hand

Joined: Dec 06, 2011
Posts: 51

Hi !

Maybe problem is in variable "counter," that has value equal 20. Your "coursor" has 20 elements counted from 0 - 19 .. so .. if you try to get element with index 20 you have exception.

Bye !
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: android CursorIndexOutOfBoundsException: Index 20
 
Similar Threads
To many Frames
how to read table from mobile
basic radiobutton question
Event handling
Frame Attack!