title: Add number to contact on Android 2.0
body: <p>Im trying to add a phone number to an already existing contact on a Droid-phone. Doing it at the same time as I create a contact is trivial, as the backreference I supply simply is 0 when creating a ContentProviderOperation. But trying to find the backreference through querying for a display name like this does not work:</p>
  
  <pre><code>Cursor rawContactsReferenceCursor = 
              contentResolver.query(Data.CONTENT_URI, 
                      new String[]{Data.RAW_CONTACT_ID},
                      Data.DISPLAY_NAME+"=\""+displayName+"\"", null, null);
  </code></pre>
  
  <p>While I do get a raw contact ID, the following code just generates an IndexOutOfBoundException (rawConcactReferenceID is the variable I got from the previous query):</p>
  
  <pre><code>ArrayList&lt;ContentProviderOperation&gt; op_list = 
      new ArrayList&lt;ContentProviderOperation&gt;();
  op_list.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
      .withValueBackReference(Data.RAW_CONTACT_ID, rawConcactReferenceID)
      .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
      .withValue(Phone.NUMBER, testNumber)
      .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
      .withValue(Phone.LABEL, testLabel)
      .build()); 
  ContentProviderResult[] result =
      contentResolver.applyBatch(ContactsContract.AUTHORITY, op_list);
  </code></pre>
  
  <p>The big challenge is a huge lack of good documentation. I would be very satisfied to just get my hands on some working copypasta to study.</p>
  
  <p>Cheers,</p>