title: How to create a contact programmatically
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4744187/how-to-add-new-contacts-in-android">How to add new contacts in android</a>  </p>
  </blockquote>
  
  
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>I am getting NullPointer Exception I don't know why I have also specified <strong>WRITE_CONTACTS</strong> Permission.  Please help me ............ </p>