I'm trying to use ContactsContract API to add some notes to my contacts, I'm not sure I'm full By way of understanding different contact IDs and raw contact IDs. My problem seems to be similar to discussions.
I want to: 1. Find a specific contact. 2. When found, insert a specific note
I am doing it in the following way:
cursor contact = getContentResolver (). Query (ContactsContract.Data.CONTENT_URI, null, null, null, void); While (contacts.moveToNext ()) {Log D. ("TC", "found:" + name); Get rid of int = contacts.getColumnIndex (ContactsContract.Data.RAW_CONTACT_ID); Int rawContactID = contacts.getInt (get rid of); Int nameIdx = contacts.getColumnIndex (ContactsContract.Data.DISPLAY_NAME); String name = contacts.getString (nameIdx); If & lt; Some condition & gt; {ContentValues contentValues = New Content Price (); ContentValues.put (ContactContact.Data .RW_CONTACT_ID, rawContactID); ContentValues.put (ContactContact.Data. M.T.T.E.E.P., ContactContact.comCommandityind NoteNotcontentMTMEPE); ContentValues.put (ContactContact.comCommandetind NoteNote, "Buzing!"); Int State = getContentResolver () Update (ContactsContract.Contacts.CONTENT_URI, contentValues, null, null); Log D. ("TC", "Update returned:" + State); }} I did not get any errors but the contact is not updated: (
Change
GetContentResolver () .Update (...) with DataContentResolver (.content. CONTENT_URI, contentValues); in addition, you must make a statement to the data. CONTENT_URI query, because you can have multiple entries in the data table with the same raw_contact_id. you can use the "Data.MIMETYPE = StructuredName.CONTENT_ITEM_TYPE"
Comments
Post a Comment