Questions tagged [android-contacts]

Content related to Android's Contacts APIs

The Contacts provider stores all information about contacts.

Android SDK Reference

2070 questions
71
votes
15 answers

Read all contacts' phone numbers in android

I'm using this code to retrieve all contact names and phone numbers: String[] projection = new String[] { People.NAME, People.NUMBER }; Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + "…
shuwo
  • 879
  • 2
  • 8
  • 7
54
votes
6 answers

Android: Retrieve contact name from phone number

I would like to retrieve the name of a contact associated with an incoming telephone number. As I process the incoming number in the broascastreceiver having a String with the name of the incoming caller would help my project greatly. I would think…
Noah Seidman
  • 4,359
  • 5
  • 26
  • 28
42
votes
6 answers

Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord in Android Studio

I am getting this error when I am trying to read contacts from phone and I included READ_CONTACTS permission in Manifest file. And the strange thing is that it was working fine in Eclipse but when I converted my project to Gradle and run it in…
Navakanth
  • 834
  • 1
  • 12
  • 24
35
votes
4 answers

onActivityResult For Fragment

I currently have a base activity which is hosting a single fragment. Inside the fragment I have a method which starts the contact chooser. private void chooseContacts() { Intent pickContactIntent = new Intent(Intent.ACTION_PICK, …
Nath5
  • 1,665
  • 5
  • 28
  • 46
33
votes
17 answers

Pick a Number and Name From Contacts List in android app

i want to pick a contact with it's number from my contacts list. i read a lot of solutions and research for couple weeks but all of articles didn't work properly. some codes like following: Intent intent = new Intent(Intent.ACTION_PICK,…
aTa
  • 641
  • 2
  • 8
  • 20
30
votes
2 answers

Search contact by phone number

In my app, user writes a phone number, and I want to find the contact name with that phone number? I usually search the contacts like this: Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null,…
Tiago Costa
  • 4,151
  • 12
  • 36
  • 54
30
votes
3 answers

What does COLLATE LOCALIZED ASC stand for?

private Cursor getContacts() { // Run query Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; …
Pentium10
  • 204,586
  • 122
  • 423
  • 502
29
votes
7 answers

Android get all contacts telephone number in ArrayList

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 ContactsContract?
Karl-John Chow
  • 775
  • 2
  • 8
  • 26
27
votes
7 answers

How to remove a contact programmatically in android

I try the following code to remove contact with a specified number: private void removeContact(Context context, String phone) { //context.getContentResolver().delete(Contacts.Phones.CONTENT_URI, phone, null); …
yinglcs
  • 2,891
  • 6
  • 26
  • 20
27
votes
3 answers

Inserting contacts in Android 2.2

I am trying to insert new RawContact contacts, but the RawContact added doesn't get displayed when I view the contacts through Contacts or phonebook. As I understand if we create a RawContact and there is no contact associated with it then the…
Alok Save
  • 202,538
  • 53
  • 430
  • 533
26
votes
0 answers

How to get whatsapp Contacts from Android Programmatically?

I have to try to get WhatsApp contacts from phone and I get a total Count of WhatsApp contact but from RawContacts how to get WhatsApp numbers and names that I don't know. I have tried to find a solution but can't get the exact solution for that.…
25
votes
7 answers

How to check if a cursor is empty?

When I'm trying to get the phone numbers from the contact list of the phone. The problem is, when I'm running the app while the contact list in the phone is empty, the app is stopped. I checked it and this is because the cursor is empty. How can I…
Yossi Zloof
  • 1,609
  • 3
  • 13
  • 13
25
votes
9 answers

Insert a new contact intent

For one of my apps, I need the user to select one of his existing contacts or to create a new one. Picking one is clearly easy to do with the following code: i = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(i,…
Manitoba
  • 8,522
  • 11
  • 60
  • 122
24
votes
9 answers

How to get the first name and last name from Android contacts?

How to get the following fields from Android contacts? I used Android 2.2. Name prefix First name Middle name Last name Name prefix Phonetic given name Phonetic middle name Phonetic family name
bharath
  • 14,283
  • 16
  • 57
  • 95
22
votes
6 answers

permission.READ_CONTACTS does not seem to work

I'm working on a simple app that browses through the user's contacts. Unfortunately I keep getting the following error: java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.HtcContactsProvider2 uri…
Danielvd
  • 341
  • 1
  • 2
  • 4
1
2 3
99 100