after bootup,crashing

旧时模样 提交于 2019-12-01 12:40:06

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.

From the error it seems that you are fetching some content from the Database in the Cursor. But fetching the content from the Cursor you need to point the Cursor to the first row that your cursor contains. So you need to apply cursor.moveToFirst(); to get it working, if this is the case. Else you should post the full source or the code where you feel its crashing.

The error says that you are trying to receive the string from the column with index -1 which is WRONG. Columns are enumerated starting from 0. As google's doc says about Cursor.getColumnIndex(String name), it returns -1 if the column with "name" name doesn't exist. Check the line 69 of your MyService.java file:

String num1 = cursor2.getString(cursor2.getColumnIndex("secure"));

I think there is no "secure" column in your database. Verify your database.

subrussn90

I found the answer for this myself...

the error,rather say;my mistake in coding was that i was supposed to use moveToNext() instead of isAfterLast()

Where is the database located? And are you sure you have your permissions set? Also, could you post the code to your MyService Class?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!