在android中获取联系人
我通过 Android 模拟器插入了一些联系人。
我想获取姓名、号码、电子邮件等。对于每个联系人。
我明白,为了获取联系号码,我们需要参考
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
而不是
ContactsContract.Contacts.CONTENT_URI
我的问题是如何链接两个查询结果,以便我可以将单个联系人及其属性聚合在一起?似乎只有 ContactsContract.Data.DISPLAY_NAME 在结果中是通用的,也是唯一可以在两个 URI 中获取而无需在查询投影中指定的属性。
有人可以指导我吗?
谢谢, 阿迪亚。
I have inserted few contacts in through the android emulator.
I wanted to fetch the names, number,emails,etc. for each contact.
I understood that for fetching contact number we need to refer to
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
instead of
ContactsContract.Contacts.CONTENT_URI
My question is how do i link both the query results so that i can aggregate a single contact and its attributes together ? It seems that only ContactsContract.Data.DISPLAY_NAME is common in both the results and the only attribute which can fetched in both the URI's without specifying in the query's projection.
Can anyone guide me ?
Thanks,
Adithya.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试以下链接:
如何调用 Android 联系人列表?
如何从android中的本机电话簿获取联系人
如何在 Android 中获取联系人的所有详细信息
如何从 Android 获取名字和姓氏联系人?
如何将联系人从电话簿导入到我们的应用程序
Android 联系人提取
如何获取所有Android联系人但没有SIM 卡上的内容
try these links:
How to call Android contacts list?
How to get contacts from native phonebook in android
How to obtain all details of a contact in Android
How to get the first name and last name from Android contacts?
How to import contacts from phonebook to our application
Android contacts extraction
How to get all android contacts but without those which are on SIM
使用
ContactsContract.Data.CONTENT_URI
中的选择并按LOOKUP_KEY
对结果进行分组。您将收到一个光标,其中包含按联系人分组的电话、电子邮件等。Use select from
ContactsContract.Data.CONTENT_URI
and group results byLOOKUP_KEY
. You'll receive a single cursor with phones, emails, etc., grouped by contact.在onactivityresult中,我们将光标移至联系人数据库以访问联系人数据库的各个字段,我们有ContactsContract.PhoneLookup,通过它我们可以获取各种数据库列的索引,然后访问它们。
In onactivityresult we r getting cursor to the contact database to access various fields of contact database we have ContactsContract.PhoneLookup through which we can get index various db columns and then acccess them.