after bootup,crashing

前端 未结 5 1718
轮回少年
轮回少年 2021-01-16 02:40

My application is using a bootup service.In the service i have to get values from a database,but the app is crashing as it tries getting the values...

The logcat err

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-16 03:41

    When you Create Cursor from the Database you have to first check for both (cursor != null && cursor.moveToFirst()). In your case if there is no any data available then it will create a problem.

    so before you use Cursor add the condition

    if(c != null && c.moveToFirst()) {
    //write your code here
    } 
    

    java.lang.IllegalStateException: get field slot from row 0 col -1 failed

    Normally this error you will get if you are trying to read a column value from the cursor but that column is not exists in the cursor.

提交回复
热议问题