title: Android: Adding exsting contacts as favourite contact?
body: <p>I have one ListView in which i am getting all contacts of phone. in ListView  i have put the one button and on clicking on that button that contact should be added in favourites and on clicking again that should be removed from favourites.<br> Here i found the code to add new contact with favourite tag.but how to do this on clicking on button.i have tried with this code:</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>ArrayList&lt;ContentProviderOperation&gt; ops = new ArrayList&lt;ContentProviderOperation&gt;();
          int rawContactInsertIndex = ops.size();
  
          ops.add(ContentProviderOperation.newUpdate(RawContacts.CONTENT_URI)
                  .withValue(RawContacts.ACCOUNT_TYPE, null)
                  .withValue(RawContacts.ACCOUNT_NAME, null)
                  .withValue(RawContacts.STARRED, true).build());
          ops.add(ContentProviderOperation
                  .newUpdate(ContactsContract.Data.CONTENT_URI)
                  .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,
                          rawContactInsertIndex)
                  .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
                  .withValue(Phone.NUMBER, "91-0000000002").build());
          ops.add(ContentProviderOperation
                  .newUpdate(Data.CONTENT_URI)
                  .withValueBackReference(Data.RAW_CONTACT_ID,
                          rawContactInsertIndex)
                  .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
                  .withValue(StructuredName.DISPLAY_NAME, "Maulik patel").build());
  </code></pre>
  
  <p>Using this code all contacts are added to the favourite<br>
  thanks</p>