Android get all contacts telephone number in ArrayList

后端 未结 6 1218
礼貌的吻别
礼貌的吻别 2020-12-02 20:40

I am trying to save all contacts telephone numbers in an ArrayList but I cant find a way how. Is there a way to get them instead of picking them one by one with ContactsCont

6条回答
  •  情书的邮戳
    2020-12-02 21:28

    Try this:

    Cursor managedCursor = getContentResolver()
        .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
         new String[] {Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER}, null, null,  Phone.DISPLAY_NAME + " ASC");
    

    And by traversing through the cursor, you can store all this data in any data structure of your choice.

提交回复
热议问题