views:

16

answers:

0

Hi there.

This is my (non working) code to add a note to an existing contact. Where is my bug?

// ID is the ID, cr is the ContentResolver            
Uri rawContactUri =  Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,String.format("%d",ID));
Uri noteUri = Uri.withAppendedPath(rawContactUri,ContactsContract.Contacts.Data.CONTENT_DIRECTORY);
ContentValues values = new ContentValues();
values.clear(); 
values.put(ContactsContract.Data.RAW_CONTACT_ID, co.cid);
values.put(ContactsContract.Data.MIMETYPE, 
ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE); 
values.put(ContactsContract.CommonDataKinds.Note.NOTE, "blah blah"); 
cr.insert(noteUri, values);

Another code , non working at phone:

values.put(Data.RAW_CONTACT_ID,ID); 
values.put(Data.MIMETYPE, Note.CONTENT_ITEM_TYPE); 
values.put(Note.NOTE, "blah");
Uri u = cr.insert(Data.CONTENT_URI, values);

Thanks for your support.

M.