Ich entwickle eine Anwendung, wo ich Telefon, E-Mail, Website, Adresse usw. zu meinem bestehenden Kontakt auf einen Klick hinzufügen.So fügen Sie Telefon, E-Mail, Website usw. zu einem bestehenden Kontakt hinzu
die Funktion auf der Klick auf den Button geht hier
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 {
// Phone no
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(where, params)
.withValue(ContactsContract.CommonDataKinds.Phone.DATA, Tel)
.build());
// Email
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(where, params)
.withValue(ContactsContract.CommonDataKinds.Email.DATA, Email)
.build());
// Website
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(where, params)
.withValue(ContactsContract.CommonDataKinds.Website.DATA, Url)
.build());
//Organization
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(where, params)
.withValue(ContactsContract.CommonDataKinds.Organization.DATA, Org)
.build());
}
phoneCur.close();
try {
cr.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OperationApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}}
ich nicht imstande bin, mein Kontakt zu aktualisieren.
Es ist schön zu wissen, helfen, dass Sie eine Anwendung entwickeln. Ich hoffe es geht gut für dich. BTW, warum hast du das gepostet? Es ist nicht genau eine Frage, oder? –
Und was ist deine Frage? – Lucifer