title: Android contacts aggregation process
body: <p>I'm unable to find detailed information about the aggregation process in Android's contacts. I'm aware of the <code>ContactsContract.Contacts</code> -> <code>ContactsContract.RawContacts</code> -> <code>ContactsContract.Data</code> structure (as described on <a href="http://developer.android.com/guide/topics/providers/contacts-provider.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/providers/contacts-provider.html</a>), and that a <code>Contact</code> consists of <code>Raw Contacts</code>, which are grouped together through one <code>Contact_ID</code>. </p>
  
  <p>What I specifically want to know is: under what circumstances are Raw Contacts grouped into one Contact? </p>
  
  <p>I found <a href="https://android.stackexchange.com/questions/21709/how-does-android-contact-linking-work">this</a> question and answer - specifically the last option: </p>
  
  <blockquote>
    <p>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, <code>Bob Parr [incredible@android.com] = incredible@android.com</code>).</p>
  </blockquote>
  
  <p>I tried this out, however, it doesn't seem to work. I want to know if I can add a Raw Contact to the local contacts and <strong><em>set only the <code>ACCOUNT_TYPE</code>, <code>ACCOUNT_NAME</code> and phone or emailaddress</em></strong>, and if this will be automatically aggregrated with a raw contact for whom this phone number or emailaddress already exists. So for example:</p>
  
  <p>(<code>ContactsContract.Contacts.</code>)<code>_ID</code> (Similar to <code>ContactsContract.RawContacts.Contact_ID</code>): 1188300 consists of:</p>
  
  <ul>
  <li>Raw Contact ID 20905<br>
  <code>MIMETYPE = \email_v2</code><br>
  <code>ACCOUNT_TYPE = com.google</code><br>
  <code>NAME = Example Test</code><br>
  <code>EMAIL = test@gmail.com</code></li>
  <li>Raw Contact ID 20897<br>
  <code>MIMETYPE = \phone_v2</code><br>
  <code>ACCOUNT_TYPE = com.google</code><br>
  <code>NAME = Example Test</code><br>
  <code>EMAIL = 123456</code></li>
  </ul>
  
  <p>After adding the following:  </p>
  
  <ul>
  <li>Raw Contact<br>
  <code>MIMETYPE = \email_v2</code><br>
  <code>ACCOUNT_TYPE = com.exampleApp</code> 
  <code>EMAIL = test@gmail.com</code></li>
  </ul>
  
  <p><strong><em>will this result into:</em></strong>
  (<code>ContactsContract.Contacts.</code>)<code>_ID</code>: 1188300 consisting of:</p>
  
  <ul>
  <li>Raw Contact ID 20905<br>
  <code>MIMETYPE = \email_v2</code><br>
  <code>ACCOUNT_TYPE = com.google</code><br>
  <code>NAME = Example Test</code><br>
  <code>EMAIL = test@gmail.com</code></li>
  <li><p>Raw Contact ID 20897<br>
  <code>MIMETYPE = \phone_v2</code><br>
  <code>ACCOUNT_TYPE = com.google</code><br>
  <code>NAME = Example Test</code><br>
  <code>EMAIL = 123456</code>  </p></li>
  <li><p>Raw Contact ID 20899 (or whatever number)<br>
  <code>MIMETYPE = \email_v2</code><br>
  <code>ACCOUNT_TYPE = com.exampleApp</code><br>
  <code>NAME = Example Test</code><br>
  <code>EMAIL = test@gmail.com</code></p></li>
  </ul>