Android : how to set one number to default in android contacts?

on Friday, April 17, 2015


i wanna set one number to default in android contact but i don't know whats should write instead `Phone.NUMBER?



ContentResolver cr = this.getContentResolver();

Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projectionPhones,
ContactsContract.CommonDataKinds.Phone.NUMBER +"=?", new String[]{"09183332222"}, null);

while(pCur.moveToNext())
{

tv.setText(pCur.getString(1));
}

ContentValues values = new ContentValues();
values.put(Phone.DISPLAY_NAME, "Test");

// values.put(Phone.NUMBER ,numberToCall);

values.put(Phone.NUMBER
,numberToCall);

int phones = getContentResolver().update(ContactsContract.RawContacts.CONTENT_URI,values,
Phone.CONTACT_ID +" = 1812", null);

0 comments:

Post a Comment