2012-01-06 49 views
0

我已經編寫了使用內容提供程序編程更新我的聯繫人列表的代碼,只要我嘗試插入不更新的電話號碼,它顯示我參考了以前的電話號碼 我貼我已經寫我已經編寫了使用內容提供程序更新我的聯繫人但不更新我的聯繫人列表的代碼

private void updateContact(String phone) { 
     if (updateUri == null) { 
      Toast.makeText(NativeContentProvider.this, "There is nothing to update, Please create a contact and then click update", Toast.LENGTH_LONG).show(); 
     } else { 
      ContentValues newPhone = new ContentValues(); 
      newPhone.put(People.Phones.TYPE, People.TYPE_MOBILE); 
      newPhone.put(People.NUMBER, phone); 
      getContentResolver().update(updateUri, newPhone, null,null); 
      Toast.makeText(NativeContentProvider.this, "Updated the phone number to: " + phone, Toast.LENGTH_SHORT).show(); 
      Log.i(getClass().getSimpleName(), "Updated the phone number"); 
     } 
    } 

我堅持

回答

0

什麼是updateUri的值的代碼? 它必須確定要更新的記錄。例如。 updateUri可以是insert()返回的URI。 Android開發人員網站提供了一些有關如何在此處構造URI的示例:http://developer.android.com/guide/topics/providers/content-providers.html

+0

這是LOG 01-06 08:29:39.667中的值:DEBUG/NativeContentProvider(502):updateURI content:// contacts/people/128 /電話/ 674 – shvivek 2012-01-06 08:31:33

相關問題