Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android get all contacts

Tags:

android

How can I get all the names of the contacts in my Android and put them into array of strings?

like image 809
fsdf fsd Avatar asked Sep 24 '12 09:09

fsdf fsd


People also ask

How do I display all contacts?

Open your Contacts app and tap the Options button (three dots), and select Contacts Manager. On the next screen, tap on Contacts to display from the menu.

How do I export my contacts more than 1000?

Step 1: First, you need to open the menu and then click “Import/Export” button. Step 2: Then click the “Export to SIM card” option. And select all the contacts. Step 3: Now all contacts will get transferred to the SIM.

Why can't I see all my contacts on my Android?

Go to Setting on your Android or Samsung. Click Account and Google account. Tap on Account sync and check if your contacts button is toggled on. If yes, you can also turn it off then on.


1 Answers

Try this too,

private void getContactList() {     ContentResolver cr = getContentResolver();     Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,             null, null, null, null);      if ((cur != null ? cur.getCount() : 0) > 0) {         while (cur != null && cur.moveToNext()) {             String id = cur.getString(                     cur.getColumnIndex(ContactsContract.Contacts._ID));             String name = cur.getString(cur.getColumnIndex(                     ContactsContract.Contacts.DISPLAY_NAME));              if (cur.getInt(cur.getColumnIndex(                     ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0) {                 Cursor pCur = cr.query(                         ContactsContract.CommonDataKinds.Phone.CONTENT_URI,                         null,                         ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",                         new String[]{id}, null);                 while (pCur.moveToNext()) {                     String phoneNo = pCur.getString(pCur.getColumnIndex(                             ContactsContract.CommonDataKinds.Phone.NUMBER));                     Log.i(TAG, "Name: " + name);                     Log.i(TAG, "Phone Number: " + phoneNo);                 }                 pCur.close();             }         }     }     if(cur!=null){         cur.close();     } } 

If you need more reference means refer this link Read ContactList

like image 158
Aerrow Avatar answered Sep 18 '22 17:09

Aerrow