I am trying to add a new contact to the Android 2.2 contacts directly.
//this code doesn\'t work
ContentValues cv=new ContentValues();
c
ContentValues cv = new ContentValues();
cv.put(People.NAME, e1.getText().toString());
// e1.getText().tostring() is Contact name
Uri u = getContentResolver().insert(People.CONTENT_URI, cv);
Uri pathu = Uri.withAppendedPath(u, People.Phones.CONTENT_DIRECTORY);
cv.clear();
cv.put(People.NUMBER, e2.getText().toString());
// e2.getText().tostring() is Contact number
getContentResolver().insert(pathu, cv);
Toast.makeText(getApplicationContext(), "Contact Added",Toast.LENGTH_LONG).show();