如何获取Android手机联系人所有详细信息的方法有哪些?

2026-04-02 12:171阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计364个文字,预计阅读时间需要2分钟。

如何获取Android手机联系人所有详细信息的方法有哪些?

通过输入联系ID,我可以获取各种联系详情(如姓名、电话、电子邮件等)通过为这些字段中的每个字段进行不同的查询。指定联系信息。

Givenacontactid,Icanobtainvariouscontactdetails(likename,phone,email-id,etc)bymaking

Given a contact id, I can obtain various contact details (like name, phone, email-id, etc) by making different queries for a each of these fields.

给定联系人ID,我可以通过对每个字段进行不同的查询来获取各种联系人详细信息(如姓名,电话,电子邮件ID等)。

But is there a method to obtain all the details associated with this contact id by making a single query?

但是,是否有方法通过进行单个查询来获取与此联系人ID相关的所有详细信息?

1 个解决方案

#1

12

Had to change a bit of the tutorial on Content Providers since it referenced deprecated classes, this might help.

不得不改变内容提供者的一些教程,因为它引用了弃用的类,这可能会有所帮助。

import android.provider.ContactsContract.Contacts;import android.database.Cursor;// Form an array specifying which columns to return, you can add more.String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone ContactsContract.CommonDataKinds.Email };Uri cOntacts= ContactsContract.Contacts.CONTENT_LOOKUP_URI;// id of the Contact to return.long id = 3;// Make the query. Cursor managedCursor = managedQuery(contacts, projection, // Which columns to return null, // Which rows to return (all rows) // Selection arguments (with a given ID) ContactsContract.Contacts._ID = "id", // Put the results in ascending order by name ContactsContract.Contacts.DISPLAY_NAME + " ASC");

如何获取Android手机联系人所有详细信息的方法有哪些?

本文共计364个文字,预计阅读时间需要2分钟。

如何获取Android手机联系人所有详细信息的方法有哪些?

通过输入联系ID,我可以获取各种联系详情(如姓名、电话、电子邮件等)通过为这些字段中的每个字段进行不同的查询。指定联系信息。

Givenacontactid,Icanobtainvariouscontactdetails(likename,phone,email-id,etc)bymaking

Given a contact id, I can obtain various contact details (like name, phone, email-id, etc) by making different queries for a each of these fields.

给定联系人ID,我可以通过对每个字段进行不同的查询来获取各种联系人详细信息(如姓名,电话,电子邮件ID等)。

But is there a method to obtain all the details associated with this contact id by making a single query?

但是,是否有方法通过进行单个查询来获取与此联系人ID相关的所有详细信息?

1 个解决方案

#1

12

Had to change a bit of the tutorial on Content Providers since it referenced deprecated classes, this might help.

不得不改变内容提供者的一些教程,因为它引用了弃用的类,这可能会有所帮助。

import android.provider.ContactsContract.Contacts;import android.database.Cursor;// Form an array specifying which columns to return, you can add more.String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone ContactsContract.CommonDataKinds.Email };Uri cOntacts= ContactsContract.Contacts.CONTENT_LOOKUP_URI;// id of the Contact to return.long id = 3;// Make the query. Cursor managedCursor = managedQuery(contacts, projection, // Which columns to return null, // Which rows to return (all rows) // Selection arguments (with a given ID) ContactsContract.Contacts._ID = "id", // Put the results in ascending order by name ContactsContract.Contacts.DISPLAY_NAME + " ASC");

如何获取Android手机联系人所有详细信息的方法有哪些?