0

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.

Gaket
  • 6,533
  • 2
  • 37
  • 67
OferR
  • 1,634
  • 19
  • 21

3 Answers3

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

Shibin Francis
  • 482
  • 6
  • 18
  • 1
    Contact ids do change. A prime example is when we clear contacts data (or reset the phone or buy a new phone) and contacts are re-synced from Google. In this example, lookup keys do not change. – OferR Nov 08 '12 at 14:06
  • See, i am talking about normal case. if you clear the contact database, it will clear complete database including id. But if u delete contacts from contact list, this will not change the id. For example if id is "2345", till you reset your phone it will not create a contact using this id. – Shibin Francis Nov 09 '12 at 06:48
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

Brad Hong
  • 389
  • 2
  • 11
  • I am working with Android 2.2. I accessed a lookup key for contact it was 0r12-2982324852 later I changed the name and saved the contact and lookupkey was 0r12-2982324852365430403C4638. So it is same for Android 2.2 also, but when I added a phone number to the same contact lookup key remained the same 0r12-2982324852365430403C4638 – Gaurav Agarwal Jun 12 '12 at 15:54
  • Android 2.2 added the first r12 part (in 0r12-2982324852365430403C4638). This is raw contact id 12, and this is how Android 2.2 can find the contact even after the name changed. – OferR Jun 12 '12 at 18:40
0

even a lookup key is changed, it will still point to same contact.

from: https://developer.android.com/guide/topics/providers/contacts-provider

The ContactsContract.Contacts table also has the column LOOKUP_KEY that is a "permanent" link to the contact row. Because the Contacts Provider maintains contacts automatically, it may change a contact row's _ID value in response to an aggregation or sync. Even If this happens, the content URI CONTENT_LOOKUP_URI combined with contact's LOOKUP_KEY will still point to the contact row, so you can use LOOKUP_KEY to maintain links to "favorite" contacts, and so forth. This column has its own format that is unrelated to the format of the _ID column.

user8462556
  • 369
  • 6
  • 13