Android: Manage contacts with lookup key

2020-05-03 19:18发布

问题:

Following up on this question:

Android: Manage contacts with lookup key

(see below)

I have the same problem. However, it shows with Android 2.1 Update 1, But is OK with Android 2.2.

It seems that the lookup key changes with contact's name change with Android 2.1, but does not change with Android 2.2.

Did anybody else experience this? Any suggested workaround for Android 2.1?

Thanks

Original question by chromate

Hi everybody,

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 ...

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

Thanks in advance.

回答1:

why don't you find contact id or lookup key via using raw contact id? this is bug in 2.1.

Lookup key was based on the contact name for unsynced contacts.

http://comments.gmane.org/gmane.comp.handhelds.android.devel/130677



回答2:

You can use contact ids instead of that. Look up key is not stable. So do not us look up key. And the benefit of contact id is it won't very. So use contact id. good luck