0

as far as you might know, there are contacts (aggregate contacts) which are formed by aggregation of two or more raw contacts in Android V2.x

is it possible to identify all the raw contacts from which a single aggregate contacts is formed through a query on the ContactsContract.Contacts or is there a way to identify these contacts at all?

i could not find any flag or database field that tells me that this aggregate contacts is linked with these raw contacts.

any suggestions?

Rupesh
  • 3,415
  • 2
  • 26
  • 30

2 Answers2

1

You can check AggregationExceptions.CONTENT_URI Table where relationship type are AggregationExceptions.TYPE_KEEP_TOGETHER, AggregationExceptions.TYPE_KEEP_SEPARATE, etc.

and you can find Raw_contact_id1 and raw_contact_id2.

Example of data into database. Lets say 1,2,3,4 are in relation so you can find following pairs. Raw_contact_id1 raw_contact_id2 Relationship type 1-> 2, 1->3, 1->4, 2->3, 2->4, 3->4

biegleux
  • 13,179
  • 11
  • 45
  • 52
Ruchit Mittal
  • 312
  • 1
  • 9
0

A Contact cannot be created explicitly. When a raw contact is inserted, the provider will first try to find a Contact representing the same person. If one is found, the raw contact's CONTACT_ID column gets the _ID of the aggregate Contact. If no match is found, the provider automatically inserts a new Contact and puts its _ID into the CONTACT_ID column of the newly inserted raw contact.

So, while reading all the contacts one by one we can take its _ID value and can retrieve all the contacts from raw_contacts where _ID matches with raw_contacts.CONTACT_ID. If the count is greater than 1 then we can conclude that it is linked with those numbers of contacts else it is not linked with any other contact.

Rupesh
  • 3,415
  • 2
  • 26
  • 30