How to read contacts on Android 2.0

前端 未结 9 1163
我寻月下人不归
我寻月下人不归 2020-11-22 05:58

I\'m working on Android 2.0 and am trying to receive a list of all contacts.

Since android.provider.Contacts.People is deprecated, I have to use android

9条回答
  •  無奈伤痛
    2020-11-22 06:07

    Put this ....

    Cursor phones = 
    
        getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
                    while (phones.moveToNext())
                    {
                    String Name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
                    String Number=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
    }
    

    Let me know if any issue.

提交回复
热议问题