0

while retrieving data from sqlite getting below exception.

11-19 11:37:43.357: E/AndroidRuntime(1494): java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.

query is -

 Cursor c= db.rawQuery("SELECT * FROM "+OpenHelper.TABLE_ACTIVITY_DETAIL+" WHERE "+OpenHelper.Activity_Date+" = '"+date+"'",null);

    if(c != null){
        if (c.moveToFirst()){
            do{
                task=c.getString(c.getColumnIndex("task"));
                activityList.add(""+task); 
            }while(c.moveToNext());
        }
    }
    c.close();  
    db.close();

is there any solution?

yuva ツ
  • 3,707
  • 9
  • 50
  • 78

1 Answers1

0

Clearly there is no such column named 'task'. Please confirm your column name at the following line.

 task=c.getString(c.getColumnIndex("task"));

Confirm your column name and you are good to go.

Nitesh
  • 3,868
  • 1
  • 20
  • 26