Xamarin.android using SQLite to appear Index-1 requested with a size of 10 exception

Source: Internet
Author: User
Tags sqlite

Exception: Android.database.cursorindexoutofboundsexception:index-1 requested, with a size of 10

This error is that the data returned to ICursor cannot determine the index of the Get column, so you need to add a bit of code.

if 0)             // Determining cursor Position {    IC. Movetofirst ();} Else {    IC. MoveToNext ();}

Full Code Demo:

/// <summary>///Querying Data/// </summary>voidQuerydata () {icursor IC= Localhost_database.query ("Tb_person",NULL,NULL,NULL,NULL,NULL,NULL);  for(inti =0; I < IC. Count; i++)    {        if(i = =0)//Determining cursor Position{IC.        Movetofirst (); }        Else{IC.        MoveToNext (); } Person=NewPerson (); Person. Id= IC. GetString (IC. Getcolumnindex ("Id")); Person. Name= IC. GetString (IC. Getcolumnindex ("name")); Person. Age= IC. GetString (IC. Getcolumnindex (" Age")); Person. Sex= IC. GetString (IC. Getcolumnindex ("Sex")); Person. Idcard= IC. GetString (IC. Getcolumnindex ("Idcard")); List.     ADD (person); } lv_person.adapter=NewListviewadapter ( This, list);}

Xamarin.android using SQLite to appear Index-1 requested with a size of 10 exception

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.