2016-11-29 38 views

回答

0

您需要更新的ContactsContract.ContactsSEND_TO_VOICEMAIL領域:

long contactId = <your contact id>; 
ContentResolver contentResolver = getContentResolver(); 
ContentProviderOperation update = ContentProviderOperation 
      .newUpdate(Data.CONTENT_URI) 
      .withSelection(Data.CONTACT_ID + "=" + contactId, null) 
      .withValue(Contacts.SEND_TO_VOICEMAIL , 1) 
      .build(); 
update.apply(contentResolver, null, 0); 
+0

感謝您的答覆。但我無法嘗試這個代碼1.什麼將contactId,我怎麼能得到它和2. contentProvider,如何初始化?你可以請詳細說明代碼嗎?它會幫助我寫出很多 –

+0

'我想移動我的應用程序添加的聯繫人',我假設你至少有剛剛創建的聯繫人的聯繫人ID。關於'ContentProvider',這是一個錯字,我的意思是'ContentResolver',我已經更新回答如何獲得它(假設你在一個活動中) – marmor

相關問題