コード例 #1
0
ファイル: ContactHelper.java プロジェクト: BenEdridge/apg
  /**
   * Delete all raw contacts associated to OpenKeychain, including those from "me" contact defined
   * by ContactsContract.Profile
   *
   * @return number of rows deleted
   */
  private static int debugDeleteRawContacts(ContentResolver resolver) {
    // 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();

    Log.d(Constants.TAG, "Deleting all raw contacts associated to OK...");
    int delete =
        resolver.delete(
            deleteUri,
            ContactsContract.RawContacts.ACCOUNT_TYPE + "=?",
            new String[] {Constants.ACCOUNT_TYPE});

    Uri mainProfileDeleteUri =
        ContactsContract.Profile.CONTENT_RAW_CONTACTS_URI
            .buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
            .build();

    delete +=
        resolver.delete(
            mainProfileDeleteUri,
            ContactsContract.RawContacts.ACCOUNT_TYPE + "=?",
            new String[] {Constants.ACCOUNT_TYPE});

    return delete;
  }
コード例 #2
0
ファイル: ContactHelper.java プロジェクト: BenEdridge/apg
  private static int deleteFlaggedNormalRawContacts(ContentResolver resolver) {
    // 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 resolver.delete(
        deleteUri,
        ContactsContract.RawContacts.ACCOUNT_TYPE
            + "=? AND "
            + ContactsContract.RawContacts.DELETED
            + "=?",
        new String[] {Constants.ACCOUNT_TYPE, "1"});
  }
コード例 #3
0
ファイル: ContactHelper.java プロジェクト: BenEdridge/apg
  /**
   * Deletes raw contacts from ContactsContract.RawContacts based on masterKeyId. Does not delete
   * contacts from the "me" contact defined in ContactsContract.Profile
   *
   * @param resolver
   * @param masterKeyId
   * @return number of rows deleted
   */
  private static int deleteRawContactByMasterKeyId(ContentResolver resolver, 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 resolver.delete(
        deleteUri,
        ContactsContract.RawContacts.ACCOUNT_TYPE
            + "=? AND "
            + ContactsContract.RawContacts.SOURCE_ID
            + "=?",
        new String[] {Constants.ACCOUNT_TYPE, Long.toString(masterKeyId)});
  }