Android SqList mid-range subscript cross-over problem solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.