简体   繁体   English

如何在Android联系人列表中获取联系人的ID?

[英]How to get the id of the contact on Android contact list?

Hey, I want to get the id of the contact which is in the list of contacts on Android. 嘿,我想获取Android上联系人列表中的联系人ID。 I mean, when I add a contact to the phone, I think it has an Id, what is the class that provides this parameter? 我的意思是,当我将联系人添加到电话中时,我认为它具有ID,提供此参数的类是什么? I mean the exactly Id. 我的意思是确切的ID。

I've search if some constants on CallLog.Calls can provide it, but I didn't found. 我已经搜索了CallLog.Calls上的某些常量是否可以提供它,但是我没有找到。 Maybe it's Contacts.Contract, I don't know. 也许是Contacts.Contract,我不知道。 Does anyone knows? 有谁知道吗

Thanks! 谢谢!

Depends on the lowest API level you want to support. 取决于您要支持的最低API级别。 If it is API level 5 (2.0 Eclair) and above then ContactsContract.Contacts should be the class you are looking for. 如果它是API级别5(2.0 Eclair)或更高,则ContactsContract.Contacts应该是您要查找的类。 If you are developing for API levels below then the Contacts class is your friend. 如果您正在开发低于API的级别,那么Contacts类是您的朋友。

I may be misunderstanding the question but it sounds like psyhclo is asking about the "_id" column value for newly added contacts. 我可能对这个问题有误解,但听起来像是psyhclo正在询问新添加的联系人的“ _id”列值。 That is a question about the backing store (sqlite). 这是关于后备存储(sqlite)的问题。 If that is the case then the id is available in several ways (including the uri returned by the insert). 如果是这种情况,则可以通过多种方式使用ID(包括插入内容返回的uri)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM