如何在Android 2.0的联系人添加自定义数据/场? [英] How to add custom data/field in contacts in android 2.0?

查看:124
本文介绍了如何在Android 2.0的联系人添加自定义数据/场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个...应用程序,其中用户可以输入自己的姓名,电话号码,Facebook的ID /微博ID等,然后将被添加到现有的联系人应用程序。

I'm trying to write an application where a user can enter his name, phone number, Facebook ID/ Twitter ID etc...which will then be added to the existing contacts application.

姓名,电话号码 - 默认情况下在联系人应用程序的存在。我该如何去加入Facebook的ID或Twitter ID?我的意思是从我的应用程序中的联系人应用程序自定义字段。

Name, phone number - by default exists in the contacts app. How can I go about adding the Facebook ID or Twitter ID? I mean custom fields in the contacts application from my application.

推荐答案

您可以轻松地做到这一点通过插入你自己的mimetype:

You can easily do that by inserting you own mimetype:

Builder builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,0)
.withValue(ContactsContract.Data.MIMETYPE,"vnd.android.cursor.item/facebook")
.withValue("data1","bkhashfehFacebookId")

然后你可以从你自己的应用程序很容易使用(查询)方法读取自己的数据,你通过你的搜索条件MIMETYPE。

And then you can read your own data from your own application easily using (query) method and you pass you mimetype in the search criteria.

如果您想更新一个已经存在的联系人同样,你只需要在新的mimtype添加到联系人。

Also if you want to update an already existed contact, you just need to add new mimtype to that contact.

这篇关于如何在Android 2.0的联系人添加自定义数据/场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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