The following error occurred while using Android SqList
Android.database.CursorIndexOutOfBoundsException:Index requested, with a size of 14
After elimination, the wrong position is determined.
The error code is
Public arraylist<receivecontext> query (String table_name,string[] arg) { Sqlitedatabase db=getwritabledatabase (); Cursor c = db.query (table_name,null,poster+ "=?", arg,null,null,updatetime,null);// Query and get cursor arraylist<receivecontext> l=new arraylist<receivecontext> (); if (C.moveToFirst ()) {/ /Determine if the cursor is empty for (Int i=0;i<c.getcount (); i++) { c.movetoposition (i);//correct statement //c.move (i); Error Statement string getcontext= ""; int getstyle = 0; string gettime= ""; getcontext= c.getstring (C.getColumnIndex (context)); &nBsp; getstyle =c.getint (C.getcolumnindex (style)); gettime = c.getstring (C.getcolumnindex (updateTime)); receivecontext rc=new receivecontext (getContext,getStyle,getTime ); l.add (RC); }}c.close ();d b.close (); Return l;}
This is the way I write a database query, the reason for the cross-border is the use of method C.move (i); This method I estimate (to be verified) should be the current pointer +i, so it will cause a cross-border. The right approach should be
C.movetoposition (i);
This is the jump to the first position.
This article is from the "All Souls is Me" blog, please be sure to keep this source http://kinghacker.blog.51cto.com/7767090/1641208
Android SqList mid-range subscript cross-over problem solution