Android:使用查找键管理联系人 [英] Android: Manage contacts with lookup key

查看:37
本文介绍了Android:使用查找键管理联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个允许保存草稿的应用程序(使用 android 版本 >= 2.0).每个草稿都通过 ContactsContract.Contacts.LOOKUP_KEY 连接到一个联系人.我的问题是,如果我更改联系人姓名,查找键也会更改.是这样吗?

I'm currently writing a application that allows to save drafts (using android version >= 2.0). Each draft is connected to a contact via the ContactsContract.Contacts.LOOKUP_KEY. My problem is that if I change the name of my contact the lookup key changes also. Is that the way this works?

那么我需要什么查找键呢?我认为查找键永远不会改变,现在它无论如何都会改变.我对这种行为感到困惑......

So for what do I need a lookup key? I thought that the lookup key does never change and now it changes anyway. I'm confused about that behavior ...

有人可以向我解释如何永久链接到联系人吗?我应该使用 ID 而不是查找键吗?

Can someone explain to me how to link permanently to a contact? Should I use IDs instead of the lookup key?

提前致谢.

推荐答案

我的理解是查找键是结构化/分层键.因此,严格来说,它可以改变,但仍可用于通过适当的方法找回您的联系人:

It is my understanding that the lookup key is a structured / hierarchical key. Hence strictly speaking it can change, but still be used to find your contact back, by using the appropriate method:

    Uri lookupUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey);
    Uri res = ContactsContract.Contacts.lookupContact(getContentResolver(), lookupUri);

这篇关于Android:使用查找键管理联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆