title: Bulk update of more than 500 contacts
body: <p>I am developing an app that needs to update many contacts and I am getting the following error.</p>
  
  <blockquote>
    <p>android.content.OperationApplicationException: Too many content provider operations between yield points. The maximum number of operations per yield point is 500</p>
  </blockquote>
  
  <p>I tried breaking the contacts up into smaller chunks to update, but I still get the same error. The good thing is that now, some contacts are updated (previously 0 contacts are updated). Any suggestions that can help me is greatly appreciated.</p>
  
  <pre><code>    Uri uri = ContactsContract.Data.CONTENT_URI;
      String selectionUpdate = ContactsContract.CommonDataKinds.Phone._ID + " = ? AND " + ContactsContract.Contacts.Data.MIMETYPE + " = ? ";
  
      int i = 0;
      int numRowsUpdated = 0;
      int batchsize = 100;
      for (EntityPhone ep : eps) { 
          if (ep.isUpdateNumber()) {
  
              //update only when checkbox is ticked
              ops.add(ContentProviderOperation.newUpdate(uri)
                      .withSelection(selectionUpdate, new String[]{ep.getPhoneId(), ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE})
                      .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, ep.getPhoneNumberNew())
                      .build());
  
              i++;
              if (i % batchsize == 0) {
  
                  i = 0;
                  ContentProviderResult[] count = contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
  
                  if (count != null) {
                      numRowsUpdated += count.length;
                      Log.i(TAG, "batch update success" + count.length);
                  } else {
  
                      Log.w(TAG, "batch update failed");
                  }
              }
          }
      }
  
      if (i != 0) {
          ContentProviderResult[] count = contentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
      }
  </code></pre>
  
  <p>I have looked at the past questions, but they are mostly related to inserts, not updates.</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/5596354/insertion-of-thousands-of-contact-entries-using-applybatch-is-slow">Insertion of thousands of contact entries using applyBatch is slow</a></li>
  <li><a href="https://stackoverflow.com/questions/10736441/whats-the-fastest-way-to-create-large-numbers-of-contacts">Whats the fastest way to create large numbers of contacts?</a></li>
  </ul>
  
  <p>The reason why I want to update so many records at once is because my application is a 'contact number formatter' that allows the user to standardizes all the phone numbers in the phone easily. I do not have control of how many records the users want to update in a single batch. (<a href="https://play.google.com/store/apps/details?id=angel.phoneformat" rel="nofollow noreferrer">https://play.google.com/store/apps/details?id=angel.phoneformat</a>)</p>