Tôi cố gắng để thay đổi tên hiển thị của một số liên lạc lập trình:tên Chỉnh sửa số/điện thoại tiếp xúc lập trình
try {
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
.withSelection(ContactsContract.CommonDataKinds.Phone._ID + " = ?", new String[] {contact_id})
.withValue(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, "anything")
.build());
ContentProviderResult[] result = getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
Log.w("UpdateContact", e.getMessage()+"");
for(StackTraceElement ste : e.getStackTrace()) {
Log.w("UpdateContact", "\t" + ste.toString());
}
Context ctx = getApplicationContext();
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(ctx, "Update failed", duration);
toast.show();
}
contact_id
là ContactsContract.CommonDataKinds.Phone._ID
thu thập được trong hoạt động trước đó
Mã thực hiện tốt, nhưng:
ContentProviderResult[]
kết quả là null- Tên liên hệ vẫn không thay đổi ed
Tôi cũng đã thử nghiệm với Data.DISPLAY_NAME
nhưng có cùng tác dụng.
Tôi đọc hướng dẫn sử dụng: http://developer.android.com/guide/topics/providers/contacts-provider.html nhưng tôi không muốn gọi mục đích gốc.
Cảm ơn.
Thật sao? Không ai có thể giúp đỡ? – androfan