android sqlite查询数据时报错: get field slot from row 0 col -1 failed

android sqlite查询数据时报错:  get field slot from row 0 col -1 failed , 具体报错内容如下:

 12-13 09:37:49.350: ERROR/AndroidRuntime(10174): FATAL EXCEPTION: main
12-13 09:37:49.350: ERROR/AndroidRuntime(10174): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tsingh.newyear.activity/com.tsingh.newyear.activity.SmsListActivity}: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.os.Looper.loop(Looper.java:123)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.ActivityThread.main(ActivityThread.java:4627)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at java.lang.reflect.Method.invokeNative(Native Method)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at java.lang.reflect.Method.invoke(Method.java:521)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at dalvik.system.NativeStart.main(Native Method)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174): Caused by: java.lang.IllegalStateException: get field slot from row 0 col -1 failed
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.database.CursorWindow.getLong_native(Native Method)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.database.CursorWindow.getInt(CursorWindow.java:434)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:93)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at com.tsingh.newyear.dao.DatabaseHelper.queryData(DatabaseHelper.java:106)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at com.tsingh.newyear.activity.SmsListActivity.getData(SmsListActivity.java:48)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at com.tsingh.newyear.activity.SmsListActivity.onCreate(SmsListActivity.java:30)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-13 09:37:49.350: ERROR/AndroidRuntime(10174):     ... 11 more

 仔细检查代码后发现, 提示报错哪行代码的: int id = cursor.getInt(cursor.getColumnIndex(ID)); , 此处是获取ID的值, 查看上面代码后发现查询字段中没有查询ID字段,而现在又要获取这个字段的值,所以报了这个错误.  所以以后开发过程中要仔细.

你可能感兴趣的:(android,exception,sqlite)