2012-03-30 124 views

回答

0

這應該工作:

String your_contact_name = "John Doe"; 

    Cursor pCur = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME +" = ?", new String[]{your_contact_name}, null); 
    while (pCur.moveToNext()) 
    { 
     String lookupKey = pCur.getString(pCur.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); 
     Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey); 
     context.getContentResolver().delete(uri, null, null); 
    } 
相關問題