コード例 #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
  /**
   * deletes all raw contact entries in the "me" contact flagged for deletion ('hidden'), presumably
   * by the user
   *
   * @param resolver
   * @return number of raw contacts deleted
   */
  private static int deleteFlaggedMainProfileRawContacts(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.Profile.CONTENT_RAW_CONTACTS_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"});
  }