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

发布于 2024-10-06 07:40:45 字数 183 浏览 0 评论 0原文

嘿,我想获取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦中的蝴蝶 2024-10-13 07:40:45

取决于您想要支持的最低 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.

蒗幽 2024-10-13 07:40:45

我可能误解了这个问题,但听起来 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文