See the section on Automatic Aggregation of Contact Data in the Using the Contacts API from the technical resources on the Android Developers site.
As the article explains:
When a raw contact is added or modified, the system looks for matching (overlapping) raw contacts with which to aggregate it. It may not find any matching raw contacts, in which case it will create an aggregate contact that contains just the original raw contact. If it finds a single match, it creates a new contact that contains the two raw contacts. And it may even find multiple similar raw contacts, in which case it chooses the closest match.
Two raw contacts are considered to be a match if at least one of these conditions is met:
- They have matching names.
- Their names consist of the same words but in different order (for example,
"Bob Parr" and
- One of them has a common short name for the other (for example,
"Bob Parr" and
- One of them has just a first or last name and it matches the other raw contact. This rule is less reliable, so it only applies if the two raw contacts are also sharing some other data like a phone number, an email address or a nickname (for example,
Helen ["elastigirl"] = Helen Parr ["elastigirl"])
- At least one of the two raw contacts is missing the name altogether and they are sharing a phone number, an email address or a nickname (for example,
Bob Parr [email@example.com] = firstname.lastname@example.org).
When comparing names, the system ignores upper/lower case differences
(Bob=BOB=bob) and diacritical marks
(Hélène=Helene). When comparing two phone numbers the system ignores special characters such as
"(", ")", and whitespace. Also if the only difference between two numbers is that one has a country code and the other does not, then the system considers those to be a match (except for numbers in the Japan country code)
Automatic aggregation is not permanent; any change of a constituent raw contact may create a new aggregate or break up an existing one.
The article then goes on to explain the various modes that an application can assign to the raw contacts that it creates. Depending on the mode, the system will either:
- Automatically aggregate the contact as similarities are found with other contacts. Where similarities no longer exist, these aggregations will be removed.
- Never aggregate the contact with any other.
- Perform no further aggregation on a contact, even if that contact changes such that it would be taken out of an aggregate group.
Aside from this automatic aggregation, applications are also allowed to manually set up aggregate contacts. In these cases, the algorithm depends on the application.
Finally, you may manually join contacts in the People app by editing one of a pair of contacts, and selecting
Join from the overflow menu.