Samsung Electronics logo

Managing a Contact

To create engaging applications with various contacts features, you must learn to manage a contact in your address book:

  1. To retrieve a single contact, use the get() method of the AddressBook interface with the ContactID as a parameter:
    /* contactRef is retrieved by other APIs */
    var contactRef; 
       /* Retrieve the contact corresponding to the given reference */
       var addressBook =;
       var contact = addressBook.get(contactRef.contactId);
  2. To manage a single contact:
    1. Retrieve the default address book using the getDefaultAddressBook() method of the ContactManager interface.

      var addressbook =;
    2. Retrieve contacts stored in the address book by using the find() method of the AddressBook interface:

      var filter = new webapis.AttributeFilter("name.firstName", "CONTAINS", "Chris"};
      var sortMode = new webapis.SortMode("name.lastName", "ASC");
         addressbook.find(contactsFoundCB, errorCallback, filter, sortMode);
      To retrieve a specific contact, you can specify a filter and sorting order for the search operation through the filter and sortMode parameters (for attributes supported in the filter, see Contact Filter Attributes).

      In this example, contacts whose first name contains "Chris" are retrieved and sorted in the ascending order based on their last name. The filter includes the standard English characters in the uppercase and lowercase. The entire list consists of ASCII characters from 32 to 126, and from 160 to 255.

      The contacts that match the filter are returned as an array to the registered success event handler in the selected sorting order.

    3. Update or delete the found contact inside the contactsFoundCB event handler.

      In this example, the first name of the first contact is changed and the contact is updated in the address book using the update() method. The second contact is deleted using the remove() method.

      /* Define the event success callback */
      function contactsFoundCB(contacts) 
         contacts[0].name.firstName = "Christopher";
            /* Update the first found contact */
            /* Delete the second found contact */