This question already has answers here:
Closed 8 years ago.
Possible Duplicate:
How to add new contacts in android
public boolean createContact(String name, String number, String email)
{
boolean success = true;
try
{
ContentValues contentValues = new ContentValues();
ContentResolver contentResolver = getContentResolver();
contentValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
contentValues.put(Phone.NUMBER, "123254");
Uri uri = contentResolver.insert(android.provider.ContactsContract.Data.CONTENT_URI, contentValues);
if(uri==null)
{
success = false;
}
}
catch (Exception e)
{
e.printStackTrace();
success = false;
}
return success;
}
I am getting NullPointer Exception I don't know why I have also specified WRITE_CONTACTS Permission. Please help me ............