Problem :
I am trying to use the custom adapter extending cursor adapter for displaying data in the listview, So that I can display particular phone number that I have passed the id to a method in the database class however it is giving following error :
errorandroid.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
while I was trying to place the debugger in the method it is not going after the below line
mynum = mycursor.getString(mycursor.getColumnIndex("ContactNumber"));
Below is my code:
public String getNumberFromId(int my id)
{
String mynum;
mydb= this.getReadableDatabase();
Cursor mycursor = mydb.query(scheduletable, new String[] { "ContactNumber" },"_id="+myid, null, null, null, null);
mycursor.moveToFirst();
mynum = mycursor.getString(mycursor.getColumnIndex("ContactNumber"));
mycursor.close();
mydb.close();
return mynum;
}
Can someone help me to resolve my issue?