如何删除联系人列表中的所有联系人的Andr​​oid手机编程 [英] how to delete all contacts in contact list on android mobile programatically

查看:251
本文介绍了如何删除联系人列表中的所有联系人的Andr​​oid手机编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的应用程序,以便删除所有的一键式preSS接触任何一个可以很好的人能告诉我如何删除编程上只有一个按钮preSS全部来自Android手机的联系人?答案将是极大的AP preciated ...

I want to delete all the contact on one button press from my application so can any one nice person can told me how to delete all the contacts from android mobile programmatically on only one button press? answer would be greatly appreciated...

其实我是从几个小时上网,但没有得到任何合适的答案。这就是为什么我要发布我的问题,在这美好的论坛...感谢这样的论坛....

Actually I was surfing from a couple of hours but not got any appropriate answer. That's why I need to post my problem in this nice forum...thanks to such forum....

推荐答案

这是很简单的,这code将删除所有的联系人。

It is very simple, This code will remove all your contacts.

ContentResolver contentResolver = <your app context>.getContentResolver();
        Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
        while (cursor.moveToNext()) {
            String lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY));
            Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
            contentResolver.delete(uri, null, null);
        }

完成。

这篇关于如何删除联系人列表中的所有联系人的Andr​​oid手机编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆