如何获取Android联系人列表中联系人的id?
嘿,我想获取 Android 上联系人列表中联系人的 ID。我的意思是,当我向手机添加联系人时,我认为它有一个 Id,提供此参数的类是什么?我的意思是确切的 ID。
我搜索了 CallLog.Calls 上的某些常量是否可以提供它,但我没有找到。也许是 Contacts.Contract,我不知道。有谁知道吗?
谢谢!
Hey, I want to get the id of the contact which is in the list of contacts on Android. I mean, when I add a contact to the phone, I think it has an Id, what is the class that provides this parameter? I mean the exactly Id.
I've search if some constants on CallLog.Calls can provide it, but I didn't found. Maybe it's Contacts.Contract, I don't know. Does anyone knows?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取决于您想要支持的最低 API 级别。如果是 API 级别 5 (2.0 Eclair) 及以上,则 ContactsContract.Contacts 应该是您正在寻找的课程。如果您正在开发以下 API 级别,那么 Contacts 类就是您的朋友。
Depends on the lowest API level you want to support. If it is API level 5 (2.0 Eclair) and above then ContactsContract.Contacts should be the class you are looking for. If you are developing for API levels below then the Contacts class is your friend.
我可能误解了这个问题,但听起来 psyhclo 正在询问新添加的联系人的“_id”列值。
这是关于后备存储(sqlite)的问题。
如果是这种情况,那么 id 可以通过多种方式获得(包括插入返回的 uri)。
I may be misunderstanding the question but it sounds like psyhclo is asking about the "_id" column value for newly added contacts.
That is a question about the backing store (sqlite).
If that is the case then the id is available in several ways (including the uri returned by the insert).