0

While trying to read data from database, I'm getting this error:

 java.lang.IllegalStateException: Couldn't read row 4, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

The number of rows in the cursor are 24, the code is giving exception at row number 22. The code I use is the following:

while (c.moveToNext()) {
            SomeData someData = new SomeData();
            someData.setQuestion(c.getString(0)); //Exception is coming in this line
            someData.setOption1(c.getString(1));
            someData.setOption2(c.getString(2));
            someData.setOption3(c.getString(3));
            someData.setOption4(c.getString(4));
            someData.setAnswer(c.getString(5));
            outMap.put(c.getString(6), someData );
 }

The column value(string) for 22nd row record is 699059 characters long. I suspect that the error is a result of large String value.

Any idea how to fix this error?

Jainendra
  • 24,713
  • 30
  • 122
  • 169
  • I believe the limit is 2MB. [Check this SO Post](http://stackoverflow.com/questions/21432556/android-java-lang-illegalstateexception-couldnt-read-row-0-col-0-from-cursorw) – gtgaxiola May 28 '15 at 13:38
  • I have just encountered the same problem, but with fetching int value. [Check this issue](https://code.google.com/p/android/issues/detail?id=68344) and see if your problem happens in same conditions. – RobertUzar Aug 05 '15 at 12:32

1 Answers1

0

According to current implementation config_cursorWindowSize support maximum of 2 MB size.If row size exceeds then it will throw error.

anirban karak
  • 732
  • 7
  • 20