Questions tagged [contactscontract]

Android's Contacts API is defined in the android.provider.ContactsContract and related classes.

The Android platform provides a Contacts API for managing and integrating contacts from multiple accounts and from other data sources.

To handle overlapping data from multiple sources, the contacts content provider aggregates similar contacts and presents them to users as a single entity.

ContactsContract defines an extensible database of contact-related information. Contact information is stored in a three-tier data model: Contacts, Raw Contacts and Data.

More information can be found in the documentation for the ContactsContract class.

551 questions
1
vote
2 answers

Not able to read contacts in MIUI

I wrote this function to retrieve contacts in android phones: public static HashMap getAllContacts(Context context) { HashMap contactsList = new HashMap<>(); if(!contactsReadPermission(context)) …
Siddhant
  • 573
  • 6
  • 14
1
vote
1 answer

Updating own profile image - Unable to convert BLOB to string

Following code runs mostly successfully but on some devices it crashes and produces the appended error. Any ideas why or what I could do to solve this? Code byte[] photo = ...; long rawId = ...; Uri currentImageUri = ...; // retrieved via…
prom85
  • 16,896
  • 17
  • 122
  • 242
1
vote
1 answer

writeDisplayPhoto() changes the photo of another contact

I'm trying to set contact photo by using the function in the official android docs here,but the function changes the photo off completely different contact although i check the contactURI and contactID and use it to get the contact name and still…
1
vote
2 answers

How to distinct android main contact in android?

I have several raw contacts linked to one contact: _id - 130 contact_id - 17434 account_type - com.google aggregation_mode - 0 account_name - ...@gmail.com display_name - ... raw_contact_is_user_profile - 0 _id - 230 contact_id - 17434 account_type…
1
vote
1 answer

Android Contacts Contract: Is it possible to get unique id of data row?

So I know by now that Contacts are saved in three tables: Contacts table. Raw contacts table. Data table. The table that I am using: I am using the data table to read users with all their phone numbers according to and thanks to @marmor in this…
data
  • 739
  • 6
  • 17
1
vote
1 answer

How to add a new contact with an already existing DISPLAY_NAME?

This is the problem I am facing. I already have a contact named "Frank" in my contact. I need to add a new contact named "Frank". However, If I add using the below method, The new number gets added to the existing "Frank contact". How to properly…
Amal Paul
  • 201
  • 3
  • 5
1
vote
1 answer

How to launch contact detail activity of directory contact in android

I am Trying to launch the detail page of directory contacts(Some organigation contacts) with contact id. for local contacts it is working fine but not working for organigation contacts. Here is my code. (name is contact name ,idstr is directory id…
1
vote
1 answer

Backup and restore linkings to phone contacts (support changing phones as well)

I've an app where I link internal data to phone contacts via the ID. The problem is that I can't use default backup and restore mechanisms because after a phone change the contact IDs may change (and often do). Currently I offer an export and import…
prom85
  • 16,896
  • 17
  • 122
  • 242
1
vote
1 answer

Optimise thousands of SQLite queries android

I have this task where I need to query all details about every contact and back it up. The first 770 contacts take up 5-6 seconds to load while after 770 contacts, each contact takes more than a second to query all data. I understand that this is a…
1
vote
2 answers

Using ContactsContract, query matching name or email

Is it possible to do one query to ContactsContract to get a set of contacts which match either the display name or a phone number or an email address? This is essentially a join of the Contacts and Data "tables" (in quotes because they only look…
Peri Hartman
  • 19,314
  • 18
  • 55
  • 101
1
vote
2 answers

Aggregated View on Contacts with ContactsContract-API

I'm a little bit stuck with the new ContactsContract-API here. I think I don't fully understand the API and hope someone can give me a hint. I red in the documentation that Android is aggregating several RawContacts to so called "aggregated…
Christoph Haefner
  • 1,093
  • 1
  • 9
  • 25
1
vote
1 answer

Search contact name containing x

Building a device that connects to Bluetooth and retrieves contact names/numbers matching a certain "name", for example, if I search for "A - " and I have the following contacts in my phone: [0] "A - Dad " [1] "A - Mom" [2] "A - Grandmother" [3]…
1
vote
1 answer

Get only sim and device stored Contacts

I want to display a list with the names (GIVEN_NAME, FAMILY_NAME) of contacts that are stored in the Device and in SIM (I want to exlcude Account contacts). What I do now is: 1) I get all the Accounts in an accountTypesArray 2) I query RawContacts…
1
vote
2 answers

Retrieving the Phone number from a contact using "ContactsContract" by an ID?

I'm able to retrieve the display name of contact using the id Code as follows: Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, selectedid); Cursor cur = managedQuery(uri, null, null, null,…
kAnNaN
  • 3,669
  • 4
  • 28
  • 39
1
vote
1 answer

Retriving SIP adress from contact

I need to get this field: But I am struggling with my code: private void getContactList() { ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if ((cur !=…
Dim
  • 4,527
  • 15
  • 80
  • 139