Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

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. We will be using jQuery Mobile, so we have to make a reference:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <meta name="format-detection" content="telephone=no" />
            <meta name...