« first day (379 days earlier)      last day (2049 days later) » 

11:42 AM
@all: hiee
I have a question
I want to update the contact list based on the phone number
means... At the time of adding the contact... the app will check whether the contact exists on the basis of phone number and if it exists then it will update the name and the city
as inputed by the user... I am able to create the contact.... but not able to update it
private void updateContact(String name, String phone) {
ContentResolver cr = getContentResolver();

String where = ContactsContract.Data.DISPLAY_NAME + " = ? AND " +
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

if ( (null == phoneCur) ) {
createContact(name, phone);
} else {
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(where, params)
.withValue(ContactsContract.CommonDataKinds.Phone.DATA, phone)
.build());
}

phoneCur.close();

try {
cr.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OperationApplicationException e) {
 
2 messages moved from Android Discussion
 

« first day (379 days earlier)      last day (2049 days later) »