Adding new contact
<p>I want to add new contact, when i debug i didnt find any error but still i am not able to add new contact. please make a review of my code and guide me.</p>

<p>my Code:</p>

<pre><code>public final class contactadder extends Activity 
{
private EditText ETCname;
private EditText ETCPhNo;
private EditText ETCEmailId;
private Button btnSave;
String ss;
public static final String TAG = "ContactsAdder";


@Override 
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);    
    setContentView(R.layout.contact_adder);
    ETCname=(EditText)findViewById(R.id.contactNameEditText);
    ETCPhNo=(EditText)findViewById(R.id.contactPhoneEditText);
    ETCEmailId=(EditText)findViewById(R.id.contactEmailEditText);
    btnSave=(Button)findViewById(R.id.contactSaveButton);
    btnSave.setOnClickListener(new View.OnClickListener()
{
   public void onClick(View v)
  {
          String name=ETCname.getText().toString();
      String phone=ETCPhNo.getText().toString();
      String email=ETCEmailId.getText().toString();
     ArrayList&lt;ContentProviderOperation&gt; op=new ArrayList&lt;ContentProviderOperation&gt;();
                    /*  ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
                    .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, mSelectedAccount.getType()) 
                    .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, mSelectedAccount.getName()) 
            .build()); */
     op.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
             .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
             .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
             .withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name)
             .build());
     op.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
             .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
             .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
             .withValue(ContactsContract.CommonDataKinds.Phone.NUMBER,phone).build());
      Log.i(TAG,"Creating contact: " + name);        
        try
        {
            getContentResolver().applyBatch(ContactsContract.AUTHORITY, op);
            launchContactManager();
        }catch (Exception e) 
        {
            Context ctx = getApplicationContext();  
            CharSequence txt = "Contact creation failed, check logs.";      
            int duration = Toast.LENGTH_SHORT;  
            Toast toast = Toast.makeText(ctx, txt, duration); 
            toast.show();  
            //log exception
            Log.e(TAG, "Exceptoin encoutered while inserting contact: " + e);        
        }
                  }
 }
</code></pre>
