Putting cursor data into an array

后端 未结 5 427
南方客
南方客 2021-02-04 20:57

Being new in Android, I am having trouble dealing with the following:

public String[] getContacts(){
    Cursor cursor = getReadableDatabase().rawQuery(\"SELECT          


        
5条回答
  •  走了就别回头了
    2021-02-04 21:03

    When cursor is returned from a database query it is placed at index -1 that is above the first entry of the cursor so, before using the cursor to get data you have move it to its first position. For that add cursor.MoveToFirst(); after Cursor cursor = getReadableDatabase().rawQuery("SELECT name FROM contacts", null);

提交回复
热议问题