Android通过编程方式将联系人设置为收藏夹 [英] Android set contact to favorite programmatically

查看:129
本文介绍了Android通过编程方式将联系人设置为收藏夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我我是否有联系人列表,并且可以在我的应用程序中阅读它们,我想直接从我的应用程序中将联系人设置为收藏夹",以便当我再次打开电话联系人时,我可以找到联系人在Android手机的收藏夹列表中.

Can any one told me if I have a list of contact and read them in my application and I want to set contact to favorite from my application directly, so that when I open my phone contact again I will be able to find contact in the favorite list of android phone.

请帮助

推荐答案

,您必须向您的应用程序添加权限才能写入联系人内容提供者. android.permission.WRITE_CONTACTS android.permission.READ_CONTACTS

you must add permission to your application to be able to write to the contact content provider. android.permission.WRITE_CONTACTS android.permission.READ_CONTACTS

此后,您需要更新STARRED字段的值.

After that you need to update the value for the STARRED field.

ContentValues v = new ContentValues(); v.put(ContactsContract.Contacts.STARRED,1); getContentResolver().update(ContactsContract.Contacts.CONTENT_URI, v, ContactsContract.Contacts.Data.DATA1+"=?", new String[]{putThePhoneNumberHere+""});

ContentValues v = new ContentValues(); v.put(ContactsContract.Contacts.STARRED,1); getContentResolver().update(ContactsContract.Contacts.CONTENT_URI, v, ContactsContract.Contacts.Data.DATA1+"=?", new String[]{putThePhoneNumberHere+""});

这篇关于Android通过编程方式将联系人设置为收藏夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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