Samsung Electronics logo

Importing Contacts



To create engaging applications with various contacts features, you must learn to import contacts with the help of the vCard format:

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

    var addressbook = webapis.contact.getDefaultAddressBook();
    
  2. Create a new Contact object from the vCard string and add it to the default address book:

    var contact = null;
      
    try 
    {
       contact = new webapis.Contact("BEGIN:VCARD\n"+
                                   "VERSION:3.0\n"+
                                   "N:Gump;Forrest\n"+
                                   "FN:Forrest Gump\n"+
                                   "ORG:Bubba Gump Shrimp Co.\n"+
                                   "TITLE:Shrimp Man\n"+
                                   "TEL;WORK:(111) 555-1212\n"+
                                   "TEL;HOME:(404) 555-1212\n"+
                                   "EMAIL;WORK;PREF:forrestgump@example.com\n"+
                                   "END:VCARD");
    
          addressbook.add(contact);
          console.log("Contact was added with ID " + contact.id);
    }

To convert multiple strings and import them to an address book, convert the strings one by one and then use the addBatch() method of the AddressBook interface to add all the contacts at once in the batch mode.