Samsung Electronics logo

Adding a Contact



To create engaging applications with various contacts features, you must learn to add a contact to an address book:

  1. Retrieve the default system address book using the getDefaultAddressBook() method of the ContactManager interface:

    var addressbook = webapis.contact.getDefaultAddressBook();
    
  2. Create a Contact object and define its properties as a ContactInit object (the parameter of the Contact constructor):

    var contact = new webapis.Contact
    ({
       name: new webapis.ContactName({firstName: "Jeffrey", lastName: "Hyman"}),
       emails: [new webapis.ContactEmailAddress("user@domain.com")]
    });
    
  3. Add the Contact object to the default address book with the add() method of the AddressBook interface:

    addressbook.add(contact);