I have table in sqlite that contain only one record and I want to access that in cursor but facing problem I got this exception java.lang.IllegalStateException: get field slot from row 0 col -1 failed
My code is here :
c2=sql.dis();
c2.moveToFirst();
name = c2.getString(c2.getColumnIndex(DbManager.displayname));
ListName.setText("selected list"+name);
}
and this in BD class:
public Cursor dis() {
try
{
SQLiteDatabase db= this.getWritableDatabase();
String[] todo = new String[] {displayName };
Cursor cursor=db.query(displayname, todo, null, null, null,null, null);
return cursor;
}
catch(Exception ex)
{
str = ex.toString();
}
problem of above code is in this line
name = c2.getString(c2.getColumnIndex(DbManager.displayname));displayname is table name not a column name.