Example usage for android.content OperationApplicationException OperationApplicationException

List of usage examples for android.content OperationApplicationException OperationApplicationException

Introduction

In this page you can find the example usage for android.content OperationApplicationException OperationApplicationException.

Prototype

public OperationApplicationException() 

Source Link

Usage

From source file:com.android.contacts.ContactSaveService.java

/** Returns true if the batch was successfully applied and false otherwise. */
private boolean applyOperations(ContentResolver resolver, ArrayList<ContentProviderOperation> operations) {
    try {/*  w  ww .  ja  v a2  s .  co  m*/
        final ContentProviderResult[] result = resolver.applyBatch(ContactsContract.AUTHORITY, operations);
        for (int i = 0; i < result.length; ++i) {
            // if no rows were modified in the operation then we count it as fail.
            if (result[i].count < 0) {
                throw new OperationApplicationException();
            }
        }
        return true;
    } catch (RemoteException | OperationApplicationException e) {
        FeedbackHelper.sendFeedback(this, TAG, "Failed to apply aggregation exception batch", e);
        showToast(R.string.contactSavedErrorToast);
        return false;
    }
}