01 public class MainActivity extends Activity { 02 EditText vorname, nachname; 03 04 @Override 05 public void onCreate(Bundle savedInstanceState) { 06 super.onCreate(savedInstanceState); 07 setContentView(R.layout.main); 08 vorname = (EditText) findViewById(R.id.vorname); 09 nachname = (EditText) findViewById(R.id.nachname); 10 Button addContact = (Button) findViewById(R.id.kontaktanlegen); 11 addContact.setOnClickListener(new OnClickListener() { 12 public void onClick(View v) { createContact(); } 13 }); 14 } 15 16 protected void createContact() { 17 ContentValues personValues = new ContentValues(); 18 String name = vorname.getText() + " " + nachname.getText(); 19 personValues.put(Contacts.People.NAME, name); 20 personValues.put(Contacts.People.STARRED, 1); 21 Uri newPersonUri = Contacts.People.createPersonInMyContactsGroup( 22 getContentResolver(), personValues); 23 } 24 }