1
我試圖更改聯繫人的筆記部分,我得到了他們的電話號碼(receivedLocationSender)和日誌輸出提供了正確的名稱和ID,但idk如何獲取它替換聯繫人的「NOTES」部分..我目前擁有的東西完全沒有。我不能更新聯繫人的筆記部分
private void displayContacts() {
ContentResolver contentResolver = getBaseContext().getContentResolver();
ContentValues contentValues = new ContentValues();
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(receivedLocationSender));
String[] projection = new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup._ID};
Cursor cursor = contentResolver.query(
uri,
projection,
null,
null,
null);
if(cursor!=null) {
while(cursor.moveToNext()){
String contactName = cursor.getString(cursor.getColumnIndexOrThrow(PhoneLookup.DISPLAY_NAME));
String contactId = cursor.getString(cursor.getColumnIndexOrThrow(PhoneLookup._ID));
contentValues.clear();
String noteWhereParams = ContactsContract.CommonDataKinds.Note.NOTE;
String[] args = new String[] { String.valueOf(receivedLocation) };
contentValues.put(ContactsContract.CommonDataKinds.Note.NOTE, receivedLocation);
getContentResolver().update(ContactsContract.Data.CONTENT_URI, contentValues, contactId + "=?", args);
Log.d(LOGTAG, "contactMatch name: " + contactName);
Log.d(LOGTAG, "contactMatch id: " + contactId);
Log.d(LOGTAG, "contactNotes : " + ContactsContract.CommonDataKinds.Note.NOTE.toString());
}
cursor.close();
}
}
想通了,我希望這對你的作品傢伙.. – user1219926 2012-02-29 04:16:45