Code example for Uri

Methods: buildUpon, newDelete

    public static ContentProviderOperation.Builder newDeleteCpo(Uri uri,
            boolean isSyncOperation, boolean isYieldAllowed) {
        return ContentProviderOperation 
                .newDelete(addCallerIsSyncAdapterParameter(uri, isSyncOperation))
    private static Uri addCallerIsSyncAdapterParameter(Uri uri, boolean isSyncOperation) {
        if (isSyncOperation) {
            // If we're in the middle of a real sync-adapter operation, then go ahead 
            // and tell the Contacts provider that we're the sync adapter.  That 
            // gives us some special permissions - like the ability to really 
            // delete a contact, and the ability to clear the dirty flag. 
            // If we're not in the middle of a sync operation (for example, we just 
            // locally created/edited a new contact), then we don't want to use 
            // the special permissions, and the system will automagically mark 
            // the contact as 'dirty' for us! 
            return uri.buildUpon()
                    .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
        return uri;