android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0

后端 未结 7 2212
甜味超标
甜味超标 2020-11-27 14:14

I am using custom adapter extending cursor adapter for displaying data in listview, to display particular phone number i have passed the id to a method in database class but

相关标签:
7条回答
  • 2020-11-27 15:19

    try this.. this will avoid an Exception being thrown when the cursor is empty..

    if(cursor != null && cursor.moveToFirst()){
        num = cursor.getString(cursor.getColumnIndex("ContactNumber")); 
        cursor.close();
    }
    
    0 讨论(0)
提交回复
热议问题