i have written the code for updating my contact list by progamming using content provider , whenever i try to insert new phone number its not updating , its showing me the previous phone number
for reference i pasting the code which i have written
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");
}
}
i am stuck
What is the value of updateUri?
It has to identify the record you want to update. E.g. updateUri could be the URI returned by insert(). The Android developer site has some examples on how to construct the URI here: http://developer.android.com/guide/topics/providers/content-providers.html