android - Couldn't read row 0, col 0 from CursorWindow. (After app update) -
i error:
failed read row 0, column 0 cursorwindow has 0 rows, 64 columns.
and followed error :
couldn't read row 0, col 0 cursorwindow. make sure cursor initialized correctly before accessing data it.
this happens after reading database. inserting works without problems, reading throws error. also, happens after app has updated. if complete remove / uninstall app , reinstall it, app works 100%. after upgrading previous version, error.
i believe there problem in previous db , somehow not corrected unless remove instead of upgrading.
this onupgrade code:
@override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) { // drop older table if existed db.execsql("drop table if exists " + table_submissions); db.execsql("drop table if exists " + table_samples); db.execsql("drop table if exists " + table_settings); // create tables again oncreate(db); }
and retrieve values db:
string submission_id = cursor.getstring(submission_form_index);
there nothing wrong above code, works fine in cases. when user upgrades app, happens.
edit
here code i'm reading fro db (this works fine, theres nothing wrong logic here... gives error when user updates older version of app)
i removed unneccisary code:
cursor cursor = database.rawquery("select * " + table_submissions, null); arraylist<string> arraylist_submission_id = new arraylist<string>(); if(cursor.movetofirst()) { { int submission_idindex = cursor.getcolumnindex(submission_id); string submission_idindexentryid = cursor.getstring(submission_idindex); arraylist_submission_id.add(submission_idindexentryid); } while(cursor.movetonext()); } cursor.close();
and logcat errors:
12:04:04.116 23988 #23988 error cursorwindow failed read row 0, column 0 cursorwindow has 0 rows, 64 columns. 12:04:04.116 23988 #23988 error androidruntime fatal exception: main 12:04:04.116 23988 #23988 error androidruntime java.lang.illegalstateexception: couldn't read row 0, col 0 cursorwindow. make sure cursor initialized correctly before accessing data it. 12:04:04.116 23988 #23988 error androidruntime @ android.database.cursorwindow.nativegetstring(native method) 12:04:04.116 23988 #23988 error androidruntime @ android.database.cursorwindow.getstring(cursorwindow.java:438) 12:04:04.116 23988 #23988 error androidruntime @ android.database.abstractwindowedcursor.getstring(abstractwindowedcursor.java:51) 12:04:04.116 23988 #23988 error androidruntime @ com.gideon.submissions.screen_main.dosync_form_c(screen_main.java:640) 12:04:04.116 23988 #23988 error androidruntime @ com.gideon.submissions.screen_main$9.run(screen_main.java:386) 12:04:04.116 23988 #23988 error androidruntime @ android.os.handler.handlecallback(handler.java:615) 12:04:04.116 23988 #23988 error androidruntime @ android.os.handler.dispatchmessage(handler.java:92) 12:04:04.116 23988 #23988 error androidruntime @ android.os.looper.loop(looper.java:137) 12:04:04.116 23988 #23988 error androidruntime @ android.app.activitythread.main(activitythread.java:4947) 12:04:04.116 23988 #23988 error androidruntime @ java.lang.reflect.method.invokenative(native method) 12:04:04.116 23988 #23988 error androidruntime @ java.lang.reflect.method.invoke(method.java:511) 12:04:04.116 23988 #23988 error androidruntime @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) 12:04:04.116 23988 #23988 error androidruntime @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805)
edit 2:
here code row 640
string submission_form_c_idid = cursor.getstring(submission_form_c_idindex);
if ignore line , remove it, gives same error on next line.
again, code runs no errors, problem occurs after update.
edit 3:
here code above (row 640) part of... removed unneccissary code:
databasehelper = new handler_database(this); cursor cursor = databasehelper.getallunsyncedsubmissions(); string submission_form_c_id = "id"; //retrieve data db each entry not synced. if(cursor.movetofirst()) { session.arraylist_submission_c_id = new arraylist<string>(); { int submission_form_c_idindex = cursor.getcolumnindex(submission_form_c_id); string submission_form_c_idid = cursor.getstring(submission_form_c_idindex); session.arraylist_submission_c_id.add(submission_form_c_idid); } while(cursor.movetonext()); } else { //other code } cursor.close(); databasehelper.close();
failed read row 0, column 0 cursorwindow has 0 rows, 64 columns.
the cursor not contain rows.
check return value of moveto...()
make sure cursor pointing valid row before attempting read values.
Comments
Post a Comment