failed to read row 0,column -1

Before you start reading the consecutive values by using c.moveToNext() , set the cursor to the initial position, that is the beginning of your database.

c.moveToFirst()

and then start reading form it.

Might solve your problem.


if you see

failed to read row 0,column -1

It means you are trying to read from a column which doesn't exist.

If it cannot find the column name that you specify, Cursor.getColumnIndex() returns -1 and hence, is invalid.

There are two reasons for this:

  1. The column does not exist.
  2. The name of the column is incorrect. (so does not exist).

Note: the name of the column is CASE SENSITIVE when using getColumnIndex()


In your scenario:

 c.getString(c.getColumnIndex(CNAME));

Check that the CNAME variable is spelt correctly, and that a column of that name exists.

String CNAME=" ques"

Should that extra leading white space be there for example..

Tags:

Sqlite

Android