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