Example usage for android.provider ContactsContract CALLER_IS_SYNCADAPTER

List of usage examples for android.provider ContactsContract CALLER_IS_SYNCADAPTER

Introduction

In this page you can find the example usage for android.provider ContactsContract CALLER_IS_SYNCADAPTER.

Prototype

String CALLER_IS_SYNCADAPTER

To view the source code for android.provider ContactsContract CALLER_IS_SYNCADAPTER.

Click Source Link

Document

An optional URI parameter for insert, update, or delete queries that allows the caller to specify that it is a sync adapter.

Usage

From source file:org.sufficientlysecure.keychain.util.ContactHelper.java

/**
 * Deletes raw contacts from ContactsContract.RawContacts based on masterKeyId. Does not
 * delete contacts from the "me" contact defined in ContactsContract.Profile
 *
 * @return number of rows deleted//from   w ww.  j  a  v a  2 s. c om
 */
private int deleteRawContactByMasterKeyId(long masterKeyId) {
    // CALLER_IS_SYNCADAPTER allows us to actually wipe the RawContact from the device, otherwise
    // would be just flagged for deletion
    Uri deleteUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build();

    return mContentResolver.delete(
            deleteUri, ContactsContract.RawContacts.ACCOUNT_TYPE + "=? AND "
                    + ContactsContract.RawContacts.SOURCE_ID + "=?",
            new String[] { Constants.ACCOUNT_TYPE, Long.toString(masterKeyId) });
}

From source file:org.sufficientlysecure.keychain.util.ContactHelper.java

private int deleteFlaggedNormalRawContacts() {
    // CALLER_IS_SYNCADAPTER allows us to actually wipe the RawContact from the device, otherwise
    // would be just flagged for deletion
    Uri deleteUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build();

    return mContentResolver.delete(deleteUri,
            ContactsContract.RawContacts.ACCOUNT_TYPE + "=? AND " + ContactsContract.RawContacts.DELETED + "=?",
            new String[] { Constants.ACCOUNT_TYPE, "1" });
}

From source file:es.example.contacts.ui.ContactDetailFragment.java

private static Uri addCallerIsSyncAdapterParameter(Uri uri, boolean isSyncOperation) {
    if (isSyncOperation) {
        return uri.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build();
    }/* w  ww  .ja v a2s .  c o  m*/
    return uri;
}

From source file:org.kontalk.sync.Syncer.java

private int deleteAll(Account account, ContentProviderClient provider) throws RemoteException {
    return provider.delete(RawContacts.CONTENT_URI.buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
            .appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
            .appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type).build(), null, null);
}

From source file:org.kontalk.sync.Syncer.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private int deleteProfile(Account account, ContentProviderClient provider) throws RemoteException {
    return provider.delete(ContactsContract.Profile.CONTENT_RAW_CONTACTS_URI.buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
            .appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
            .appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type).build(), null, null);
}