O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listing all available contacts

Developers can access, read from, and filter the contacts saved within the device's contact database, allowing them to query and work with the address book on the device.

How to do it...

We will create an application to read all contacts in the device database and output them as a list:

  1. Firstly, create a new PhoneGap project named readcontact by running the following command:
    phonegap create readcontact com.myapp.readcontact readcontact
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:
    cordova platform add ios
    cordova platform add android
    
  3. Add the contact plugins by running this command:
    cordova plugin add org.apache.cordova.contacts
    
  4. Open www/index.html, and let's clean up the unnecessary elements. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required