public static class ContactsContract.Contacts
extends Object
implements BaseColumns, ContactsContract.ContactsColumns, ContactsContract.ContactOptionsColumns, ContactsContract.ContactNameColumns, ContactsContract.ContactStatusColumns
java.lang.Object | |
↳ | android.provider.ContactsContract.Contacts |
联系人表的常量,其中包含表示同一个人的每个原始联系人汇总的记录。
CONTACT_ID
column gets the _ID of the aggregate Contact. If no match is found, the provider automatically inserts a new Contact and puts its _ID into the
CONTACT_ID
column of the newly inserted raw contact.
TIMES_CONTACTED
,
LAST_TIME_CONTACTED
,
STARRED
,
CUSTOM_RINGTONE
,
SEND_TO_VOICEMAIL
. Changing any of these columns on the Contact also changes them on all constituent raw contacts.
CONTENT_LOOKUP_URI
instead of CONTENT_URI
.PhoneLookup.CONTENT_FILTER_URI
, which is optimized for this purpose.CONTENT_FILTER_URI
URI. ContactsContract.Data
table. The result will contain contact ID, name etc. Contacts | |||
---|---|---|---|
long | _ID |
read-only | Row ID. Consider using LOOKUP_KEY instead. |
String | LOOKUP_KEY |
read-only | An opaque value that contains hints on how to find the contact if its row id changed as a result of a sync or aggregation. |
long | NAME_RAW_CONTACT_ID | read-only | The ID of the raw contact that contributes the display name to the aggregate contact. During aggregation one of the constituent raw contacts is chosen using a heuristic: a longer name or a name with more diacritic marks or more upper case characters is chosen. |
String | DISPLAY_NAME_PRIMARY | read-only | The display name for the contact. It is the display name contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID column. |
long | PHOTO_ID |
read-only | Reference to the row in the ContactsContract.Data table holding the photo. That row has the mime type CONTENT_ITEM_TYPE . The value of this field is computed automatically based on the IS_SUPER_PRIMARY field of the data rows of that mime type. |
long | PHOTO_URI |
read-only | A URI that can be used to retrieve the contact's full-size photo. This column is the preferred method of retrieving the contact photo. |
long | PHOTO_THUMBNAIL_URI |
read-only | A URI that can be used to retrieve the thumbnail of contact's photo. This column is the preferred method of retrieving the contact photo. |
int | IN_VISIBLE_GROUP |
read-only | An indicator of whether this contact is supposed to be visible in the UI. "1" if the contact has at least one raw contact that belongs to a visible group; "0" otherwise. |
int | HAS_PHONE_NUMBER |
read-only | An indicator of whether this contact has at least one phone number. "1" if there is at least one phone number, "0" otherwise. |
int | TIMES_CONTACTED |
read/write | The number of times the contact has been contacted. See markAsContacted(ContentResolver, long) . When raw contacts are aggregated, this field is computed automatically as the maximum number of times contacted among all constituent raw contacts. Setting this field automatically changes the corresponding field on all constituent raw contacts. |
long | LAST_TIME_CONTACTED |
read/write | The timestamp of the last time the contact was contacted. See markAsContacted(ContentResolver, long) . Setting this field also automatically increments TIMES_CONTACTED . When raw contacts are aggregated, this field is computed automatically as the latest time contacted of all constituent raw contacts. Setting this field automatically changes the corresponding field on all constituent raw contacts. |
int | STARRED |
read/write | An indicator for favorite contacts: '1' if favorite, '0' otherwise. When raw contacts are aggregated, this field is automatically computed: if any constituent raw contacts are starred, then this field is set to '1'. Setting this field automatically changes the corresponding field on all constituent raw contacts. |
String | CUSTOM_RINGTONE |
read/write | A custom ringtone associated with a contact. Typically this is the URI returned by an activity launched with the ACTION_RINGTONE_PICKER intent. |
int | SEND_TO_VOICEMAIL |
read/write | An indicator of whether calls from this contact should be forwarded directly to voice mail ('1') or not ('0'). When raw contacts are aggregated, this field is automatically computed: if all constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set to '1'. Setting this field automatically changes the corresponding field on all constituent raw contacts. |
int | CONTACT_PRESENCE |
read-only | Contact IM presence status. See ContactsContract.StatusUpdates for individual status definitions. Automatically computed as the highest presence of all constituent raw contacts. The provider may choose not to store this value in persistent storage. The expectation is that presence status will be updated on a regular basis. |
String | CONTACT_STATUS |
read-only | Contact's latest status update. Automatically computed as the latest of all constituent raw contacts' status updates. |
long | CONTACT_STATUS_TIMESTAMP |
read-only | The absolute time in milliseconds when the latest status was inserted/updated. |
String | CONTACT_STATUS_RES_PACKAGE |
read-only | The package containing resources for this status: label and icon. |
long | CONTACT_STATUS_LABEL |
read-only | The resource ID of the label describing the source of contact status, e.g. "Google Talk". This resource is scoped by the CONTACT_STATUS_RES_PACKAGE . |
long | CONTACT_STATUS_ICON |
read-only | The resource ID of the icon for the source of contact status. This resource is scoped by the CONTACT_STATUS_RES_PACKAGE . |
Nested classes |
|
---|---|
class |
ContactsContract.Contacts.AggregationSuggestions
包含所有聚合建议(其他联系人)的单个联系人聚合的只读子目录。 |
class |
ContactsContract.Contacts.Data 包含所有组成原始联系人 |
class |
ContactsContract.Contacts.Entity
包含其所有 |
class |
ContactsContract.Contacts.Photo 包含联系人的主要照片的单个联系人的只读子目录。 |
Constants |
|
---|---|
String |
CONTENT_ITEM_TYPE 一个人的 |
String |
CONTENT_TYPE 提供人员目录的MIME类型 |
String |
CONTENT_VCARD_TYPE 一个人的 |
String |
EXTRA_ADDRESS_BOOK_INDEX 将这个查询参数添加到一个URI以获取由地址簿索引分组的行计数作为游标额外。 |
String |
EXTRA_ADDRESS_BOOK_INDEX_COUNTS 相应组的组计数数组。 |
String |
EXTRA_ADDRESS_BOOK_INDEX_TITLES 地址簿索引标题数组,按照与游标中的数据相同的顺序返回。 |
String |
QUERY_PARAMETER_VCARD_NO_PHOTO 可用于 |
Inherited constants |
---|
From interface android.provider.BaseColumns
|
From interface android.provider.ContactsContract.ContactsColumns
|
From interface android.provider.ContactsContract.ContactOptionsColumns
|
From interface android.provider.ContactsContract.ContactNameColumns
|
From interface android.provider.ContactsContract.ContactStatusColumns
|
Fields |
|
---|---|
public static final Uri |
CONTENT_FILTER_URI 内容:// style |
public static final Uri |
CONTENT_FREQUENT_URI 内容://风格URI,用于显示经常联系的人员列表。 |
public static final Uri |
CONTENT_GROUP_URI |
public static final Uri |
CONTENT_LOOKUP_URI 这个表的content:// style URI,用于创建快捷方式或以其他方式创建联系人的长期链接。 |
public static final Uri |
CONTENT_MULTI_VCARD_URI 用于引用多个 |
public static final Uri |
CONTENT_STREQUENT_FILTER_URI 用于 |
public static final Uri |
CONTENT_STREQUENT_URI 该表格的内容://样式URI与来自 |
public static final Uri |
CONTENT_URI 该表格的内容://样式URI |
public static final Uri |
CONTENT_VCARD_URI 基准 |
public static final Uri |
ENTERPRISE_CONTENT_FILTER_URI 它支持类似于 |
Public methods |
|
---|---|
static Uri |
getLookupUri(ContentResolver resolver, Uri contactUri) 构建描述所请求的 |
static Uri |
getLookupUri(long contactId, String lookupKey) 构建 |
static boolean |
isEnterpriseContactId(long contactId) 如果联系人ID来自企业档案中的联系人提供商,则返回TRUE。 |
static Uri |
lookupContact(ContentResolver resolver, Uri lookupUri) 在给定查找URI的情况下计算内容URI(请参阅 |
static void |
markAsContacted(ContentResolver resolver, long contactId) 此方法在API级别16中已被弃用。应该使用Android支持库的类DataUsageStatUpdater来代替。 |
static InputStream |
openContactPhotoInputStream(ContentResolver cr, Uri contactUri) 打开联系人的缩略图照片的InputStream并将照片作为字节流返回。 |
static InputStream |
openContactPhotoInputStream(ContentResolver cr, Uri contactUri, boolean preferHighres) 打开联系人照片的InputStream并将照片作为字节流返回。 |
Inherited methods |
|
---|---|
From class java.lang.Object
|
String CONTENT_ITEM_TYPE
一个人的 CONTENT_URI
子目录的MIME类型。
常量值:“vnd.android.cursor.item / contact”
String CONTENT_TYPE
提供人员目录的MIME类型 CONTENT_URI
。
常量值:“vnd.android.cursor.dir / contact”
String CONTENT_VCARD_TYPE
一个人的 CONTENT_URI
子目录的MIME类型。
常数值:“text / x-vcard”
String EXTRA_ADDRESS_BOOK_INDEX
将这个查询参数添加到一个URI以获取由地址簿索引分组的行计数作为游标额外。 对于大多数语言来说,它是排序键的第一个字母。 该参数不影响游标的主要内容。
Example: import android.provider.ContactsContract.Contacts; Uri uri = Contacts.CONTENT_URI.buildUpon() .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true") .build(); Cursor cursor = getContentResolver().query(uri, new String[] {Contacts.DISPLAY_NAME}, null, null, null); Bundle bundle = cursor.getExtras(); if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) && bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) { String sections[] = bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES); int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS); }
常量值:“android.provider.extra.ADDRESS_BOOK_INDEX”
String EXTRA_ADDRESS_BOOK_INDEX_COUNTS
相应组的组计数数组。 包含与EXTRA_ADDRESS_BOOK_INDEX_TITLES数组相同数量的元素。
TYPE:int []
常量值:“android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS”
String EXTRA_ADDRESS_BOOK_INDEX_TITLES
地址簿索引标题数组,按照与游标中的数据相同的顺序返回。
TYPE:String []
常量值:“android.provider.extra.ADDRESS_BOOK_INDEX_TITLES”
String QUERY_PARAMETER_VCARD_NO_PHOTO
可用于CONTENT_VCARD_URI
和CONTENT_MULTI_VCARD_URI
布尔参数,用于指示返回的vcard不应包含照片。 这对于获得节省空间的vcard非常有用。
常数值:“no_photo”
Uri CONTENT_FILTER_URI
内容:// style CONTENT_URI
URI中用于“type-to-filter”功能的CONTENT_URI
URI。 过滤器字符串将用于匹配联系人名称的各个部分。 过滤器参数应该在此URI之后作为附加路径段传递。
Uri CONTENT_LOOKUP_URI
这个表的content:// style URI,用于创建快捷方式或以其他方式创建联系人的长期链接。 此URI后面应始终加上“/”和联系人LOOKUP_KEY
。 在此之后,它可以选择性地附加一个“/”和最后一个已知的联系人ID。 这种“完整”的格式是一个重要的优化,强烈建议。
只要联系人的行ID保持不变,该URI就相当于CONTENT_URI
。 如果联系人的行ID由于同步或聚合而发生更改,则此URI将使用间接信息(同步ID或组成原始联系人)查找联系人。
查找键应该附加未编码 - 它以编码形式存储,可以在URI中使用。
Uri CONTENT_MULTI_VCARD_URI
用于引用多个Contacts
条目的基本Uri
,通过使用withAppendedPath(Uri, String)
附加LOOKUP_KEY
创建。 查找键必须与冒号(“:”)分隔符连接,并对结果字符串进行编码。 查询时提供OpenableColumns
列,或通过openAssetFileDescriptor(Uri, String)
打开时返回格式为vCard的引用联系人。
用法示例:
public Uri getAllContactsVcardUri() { Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI, new String[] {Contacts.LOOKUP_KEY}, null, null, null); if (cursor == null) { return null; } try { StringBuilder uriListBuilder = new StringBuilder(); int index = 0; while (cursor.moveToNext()) { if (index != 0) uriListBuilder.append(':'); uriListBuilder.append(cursor.getString(0)); index++; } return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI, Uri.encode(uriListBuilder.toString())); } finally { cursor.close(); } }
Uri CONTENT_STREQUENT_FILTER_URI
用于CONTENT_STREQUENT_URI
URI上的“类型到过滤器”功能的content:// style URI。 过滤器字符串将用于匹配联系人名称的各个部分。 过滤器参数应该在此URI之后作为附加路径段传递。
Uri CONTENT_STREQUENT_URI
该表格的content:// style URI与来自 ContactsContract.Data
有用数据结合 ContactsContract.Data
,过滤后只包含加星标的联系人和最常联系的联系人。
Uri CONTENT_VCARD_URI
基准Uri
用于引用单个Contacts
条目,通过使用withAppendedPath(Uri, String)
附加LOOKUP_KEY
创建。 查询时提供OpenableColumns
列,或通过openAssetFileDescriptor(Uri, String)
打开时返回格式为vCard的引用联系人。
Uri ENTERPRISE_CONTENT_FILTER_URI
它支持类似于CONTENT_FILTER_URI
语义,并返回相同的列。 这个URI需要参数DIRECTORY_PARAM_KEY
,否则会抛出IllegalArgumentException。
Uri getLookupUri (ContentResolver resolver, Uri contactUri)
建立描述所请求的 Contacts
条目的 CONTENT_LOOKUP_URI
样式 Uri
。
Parameters | |
---|---|
resolver |
ContentResolver
|
contactUri |
Uri : A CONTENT_URI row, or an existing CONTENT_LOOKUP_URI to attempt refreshing. |
Returns | |
---|---|
Uri |
Uri getLookupUri (long contactId, String lookupKey)
构建 CONTENT_LOOKUP_URI
查找 Uri
使用给定 _ID
和 LOOKUP_KEY
。
如果无法从提供的参数构造有效的查找URI,则返回null。
Parameters | |
---|---|
contactId |
long
|
lookupKey |
String
|
Returns | |
---|---|
Uri |
boolean isEnterpriseContactId (long contactId)
如果联系人ID来自企业档案中的联系人提供商,则返回TRUE。 ENTERPRISE_CONTENT_FILTER_URI
可能会返回这样的联系人。
Parameters | |
---|---|
contactId |
long
|
Returns | |
---|---|
boolean |
Uri lookupContact (ContentResolver resolver, Uri lookupUri)
在给定查找URI的情况下计算内容URI(请参阅 CONTENT_URI
)。
如果找不到联系人,则返回null。
Parameters | |
---|---|
resolver |
ContentResolver
|
lookupUri |
Uri
|
Returns | |
---|---|
Uri |
void markAsContacted (ContentResolver resolver, long contactId)
此方法在API级别16中已被弃用。
应该使用Android支持库的类DataUsageStatUpdater来代替。
将联系人标记为已联系。 更新两个字段: TIMES_CONTACTED
和LAST_TIME_CONTACTED
。 TIMES_CONTACTED字段增加1,LAST_TIME_CONTACTED字段填充当前系统时间。
Parameters | |
---|---|
resolver |
ContentResolver : the ContentResolver to use |
contactId |
long : the person who was contacted |
InputStream openContactPhotoInputStream (ContentResolver cr, Uri contactUri)
打开联系人的缩略图照片的InputStream并将照片作为字节流返回。
Parameters | |
---|---|
cr |
ContentResolver : The content resolver to use for querying |
contactUri |
Uri : the contact whose photo should be used. This can be used with either a CONTENT_URI or a CONTENT_LOOKUP_URI URI. |
Returns | |
---|---|
InputStream |
an InputStream of the photo, or null if no photo is present |
InputStream openContactPhotoInputStream (ContentResolver cr, Uri contactUri, boolean preferHighres)
打开联系人照片的InputStream并将照片作为字节流返回。
Parameters | |
---|---|
cr |
ContentResolver : The content resolver to use for querying |
contactUri |
Uri : the contact whose photo should be used. This can be used with either a CONTENT_URI or a CONTENT_LOOKUP_URI URI. |
preferHighres |
boolean : If this is true and the contact has a higher resolution photo available, it is returned. If false, this function always tries to get the thumbnail |
Returns | |
---|---|
InputStream |
an InputStream of the photo, or null if no photo is present |