I am developing an application where I have to add a phone number, email address, website, address, etc. to an existing contact with the click of a button.
function at the touch of a button is here
private void updateContact(String name) { Log.d(TAG, "in updatecontact()"); Log.d(TAG,"Contact name to be updated = "+name); ContentResolver cr = getContentResolver(); String where = ContactsContract.Data.DISPLAY_NAME + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ? AND " + String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE) + " = ? "; String[] params = new String[] {name, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_HOME)}; Cursor phoneCur = managedQuery(ContactsContract.Data.CONTENT_URI, null, where, params, null); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); if ( (phoneCur == null) ) { add_new_contact(); } else {
I canβt update my contact.
source share