title: Android write contacts
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>
  
  
  
  <p>how can i add a name to the contacts?
  I have two spinners, one for the firstname and one for the lastname. The assigned variables are linkname1 and linkname2. When user pushes the OK button (these are all in a dialog), the name (linkname1 + " " + linkname2) should be added to the contacts. I can read the contacts but how do i write it?</p>
  
  <p>Thanks</p>
  
  <p>Update:
  I also tried this:</p>
  
  <pre><code>newname = linkname1 + " " + linkname2;
  ContentValues values = new ContentValues();
  vales.put(ContactsContract.Contacts.DISPLAY_NAME, newname);
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>StringBuffer strBuf = new StringBuffer();
  strBuf.append(linkname1);
  strBuf.append(" ");
  strBuf.append(linkname2);
  ContentValues values = new ContentValues();
  values.put(ContactsContract.Contacts.DISPLAY_NAME, strBuf.toString());
  </code></pre>
  
  <p>But the new name is not appearing in the contact list.</p>