Skip to content Skip to sidebar Skip to footer

Android:java.lang.illegalstateexception: Get Field Slot From Row 0 Col -1 Failed

I am making an android database app in which when i fetch values from database using cursor It gives me the following exception. java.lang.IllegalStateException: get field slot fro

Solution 1:

Use System.out.println( cursor.getString(0)) instead of System.out.println( cursor.getString(9));

Or use System.out.println(cursor.getString(cursor.getColumnIndex("children"));

Problem in your logic:

You are fetching single column from your data base. So cursor having only one column (children). As you know that column index starts from 0 (0 for first column, 1 for 2nd column ...), you have to pass 0 in getString(). Alternate way is, to search column index in cursor and pass that with getString(). as getColumnIndex(java.lang.String) calculate the index of column name in cursor, and use it within getString(int).

Hope this will help.

Post a Comment for "Android:java.lang.illegalstateexception: Get Field Slot From Row 0 Col -1 Failed"