Android游标初始化

时间:2014-06-30 09:19:41

标签: android database sqlite cursor

到目前为止,我有一个非常奇怪的问题无法解决。

Caused by: java.lang.IllegalStateException: Couldn't read row 9, col 1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.

我搜索了类似的帖子,但仍找不到任何解决方案。

我在Sqlite中有一些数据,当我想要获取它时,我有error

以下是我提取code的{​​{1}}:

data
public static ArrayList<DetailsItemI> selectDetailsWithRecId(long recId) { int tabId; String tag, value; String selection = DBHelper.DETAILS_REC_ID + " = " + recId; Cursor c = db.query(DBHelper.DETAILS_TABLE, null, selection, null, null, null, DBHelper.DETAILS_TAB_ID + " ASC"); ArrayList<DetailsItemI> list = new ArrayList<DetailsItemI>(); DetailsItemI inputItem; if (c.moveToFirst()) { do { tabId = c.getInt(c.getColumnIndex(DBHelper.DETAILS_TAB_ID)); tag = c.getString(c.getColumnIndex(DBHelper.DETAILS_VIEW_PARAMETER)); value = c.getString(c.getColumnIndex(DBHelper.DETAILS_VALUE)); inputItem = new DetailsItem(tabId, tag, value); list.add(inputItem); } while (c.moveToNext()); } return list; } 中的{p> Column count为4,因此问题不应该在其中。我认为这是cursor问题,但不知道为什么。

感谢您提前帮助。

Full StackTrace:

row

EDITED

06-30 13:39:17.763 1033-1033/ge.altasoft.datacollector E/CursorWindow﹕ Failed to read row 9, column 1 from a CursorWindow which has 9 rows, 4 columns. 06-30 13:39:17.768 1033-1033/ge.altasoft.datacollector E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{ge.altasoft.datacollector/ge.altasoft.datacollector.DetailsActivity}: java.lang.IllegalStateException: Couldn't read row 9, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) at android.app.ActivityThread.access$700(ActivityThread.java:140) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4921) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.IllegalStateException: Couldn't read row 9, col 1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it. at android.database.CursorWindow.nativeGetLong(Native Method) at android.database.CursorWindow.getLong(CursorWindow.java:511) at android.database.CursorWindow.getInt(CursorWindow.java:578) at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69) at ge.altasoft.database.DBManager.selectDetailsWithRecId(DBManager.java:358) at ge.altasoft.datacollector.DetailsActivity.fillTheData(DetailsActivity.java:278) at ge.altasoft.datacollector.DetailsActivity.initViews(DetailsActivity.java:71) at ge.altasoft.datacollector.DetailsActivity.onCreate(DetailsActivity.java:62) at android.app.Activity.performCreate(Activity.java:5188) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)             at android.app.ActivityThread.access$700(ActivityThread.java:140)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:4921)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)             at dalvik.system.NativeStart.main(Native Method) 我应该填写很多app。我将所有这些保存为fields。部分stringsfields ImageFieldssaveimages

在一个Base64 Strings上我有3个tab Image,而Fields在提取第三个error image期间发生,但它只发生3 field。不知道为什么。

0 个答案:

没有答案