Couldn't read row 0, col -1 from CursorWindow

前端 未结 3 1581
灰色年华
灰色年华 2021-01-27 19:04

I\'m trying to get records in my table. I\'m using this code

        if(c!=null){
            if(c.moveToFirst()) {

                String tipId = c.getString(c         


        
3条回答
  •  忘了有多久
    2021-01-27 19:25

    In your code

      c.getColumnIndex(DAO.TIP_ID)
    

    is returning -1. This means value of DAO.TIP_ID doesnot match with any column name of table .Check if this value is correct and matches with a column name of the table you are accessing

    add following line before the line which causes problem and post the Logcat output here

     Log.v("out-data",DAO.TIP_ID+" "+c.getColumnIndex(DAO.TIP_ID)+" "+c.getColumnName(0));
    

    (add import statement import android.util.Log; in beginning of your code)

提交回复
热议问题