Hello I'm a newbie with manipulation of Contact API

I would create an application that saved a references to chosen
contacts and create nex contacts.

So I first think of contact id but i have read that it was a bad idea
and the lookupkey was here for that ! So I try to play with lookupKey
and i'm facing some little problems...

First :

I choose a contact to saved, I did it by getting it's lookUpKey : no
problem.
I try to access later to contact with it's lookUpKey : no problem.

I go to contact native application, I change the first name of the
choosen contact.
I go in my application an try to access to choosen contact with saved
lookUpKey : problem, the contact lookUpKey has changed because I
change the first name...

Is there a way to have a unique access to a contact ? Or I was imagine
to register to modification done on my contact ? How could I solve my
problem ?

Second :

I created a contact with this  code :


ContentValues values = new ContentValues();
Uri rawContactUri =
cr.insert(ContactsContract.RawContacts.CONTENT_URI, values);
long rawContactId = ContentUris.parseId(rawContactUri);

this.cur = this.cr.query(rawContactUri, new String[]
{ ContactsContract.RawContacts.CONTACT_ID }, null, null, null);
String id = null;
if (this.cur.moveToFirst()) {
        id =
cur.getString(cur.getColumnIndex(ContactsContract.RawContacts.CONTACT_ID));
        this.cur = this.cr.query(ContactsContract.Contacts.CONTENT_URI, null,
ContactsContract.Contacts._ID + " =  ?", new String[] { id }, null);
        if (this.cur.moveToFirst()) {
                Log.i("ContactAPI5", "LookUpCreate : " +
cur.getString(cur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)));
        } else {
                Log.i("ContactAPI5", "no contact created");
        }
}


And for these code, the result of lookUpKey is always an empty string.
Why do I have an empty string ?


Best regards

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to