Android 3.0 Couldn't read row#, column# from cursor window -
i have application runs fine on android 2.1, when trying transition 3.0 cursor error i'm not familar with.
java.lang.illegalstateexception: couldn't read row0, column -1 cursor window. make sure cursor initialized correctly before accessing data it.
all data storred in sqlite database , code works fine in android 2.1. cursor have initialized differently in android 3.0?
listed below code.
private void opengroupdata(){ sqlitedatabase db = openorcreatedatabase(database_name,context.mode_private,null); cursor cur = db.rawquery("select groupid properties group groupid" + ";" , null); linearlayout glayout = (linearlayout) findviewbyid(r.id.grouplayout); linearlayout gwindow = (linearlayout) findviewbyid(r.id.groupwindow); textview data = new textview(this); glayout.addview(data); data.settext(""); int id = cur.getcolumnindex("groupid"); int idvalue; setrequestedorientation(activityinfo.screen_orientation_user); try{ // check if our result valid. cur.movetofirst(); if (cur != null) { // loop through results {data = new textview(this); data.settextsize(20); data.setclickable(true); data.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { groupclick(v); } }); glayout.addview(data); idvalue = cur.getint(id); data.setid(idvalue); data.settext("group: " + idvalue); }while(cur.movetonext()); } cur.close(); db.close(); } catch(exception e) { toast.maketext(getapplicationcontext(), "open group exception: " + e.tostring(), toast.length_short).show(); } }
i ran same error message earlier day. turned out made typo in column name. so, if still applies, go , check column name typo's. note case sensitive aswell. error me along lines of:
//trew error c.getcolumnindex("articlenumber"); //was correct c.getcolumnindex("articlenumber");
Comments
Post a Comment