ContactAccessorSdk5.java 文件源码

java
阅读 35 收藏 0 点赞 0 评论 0

项目:alerta-fraude 作者:
@Override
/**
 * This method will remove a Contact from the database based on ID.
 * @param id the unique ID of the contact to remove
 */
public boolean remove(String id) {
    int result = 0;
    Cursor cursor = mApp.getActivity().getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,
            null,
            ContactsContract.Contacts._ID + " = ?",
            new String[] { id }, null);

    if (cursor.getCount() == 1) {
        cursor.moveToFirst();
        String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
        result = mApp.getActivity().getContentResolver().delete(uri, null, null);
    } else {
        LOG.d(LOG_TAG, "Could not find contact with ID");
    }

    return (result > 0) ? true : false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号