删除Android的特定联系人 [英] Delete specific contact in android
本文介绍了删除Android的特定联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序,我需要删除特定与从手机地址簿,但我只拿到了具体的数字不删除整个接触,所以请帮我在这。
In my application, I require to delete a particular CONTACT from phone address book, but I just got only specific number deleted not whole contact, so please help me in this.
在此先感谢。
推荐答案
要删除所有联系人使用下面的code;
To delete all contacts use the following code ;
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
while (cur.moveToNext()) {
try{
String lookupKey = cur.getString(cur.getColumnIndex(
ContactsContract.Contacts.LOOKUP_KEY));
Uri uri = Uri.withAppendedPath(ContactsContract.
Contacts.CONTENT_LOOKUP_URI, lookupKey);
System.out.println("The uri is " + uri.toString());
cr.delete(uri, null, null);
}
catch(Exception e)
{
System.out.println(e.getStackTrace());
}
}
要删除任何特定联系人的修改查询
To delete any specific contact modify the query
cr.delete(uri, null, null);
希望它可以帮助!
Hope it helps !!
这篇关于删除Android的特定联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文