This sample application demonstrates the usage of the Apache Cordova Contacts core plugin.
With the Contacts plugin, you can access the contacts database of the mobile device. You can add new entries to the database, search in the existing contacts and select entries from the database.
This sample shows how to use the methods of the Contacts plugin. It lets you create new contacts and find, clone and delete existing entries in the database. A text box prints information about your last operation.
This sample shows how to use the following plugin objects and methods.
navigator.contacts
: A global object that provides access to the contacts database of the device. The object becomes available after thedeviceready
event.navigator.contacts.create
: Creates a newcontact
object but does not save it in the contacts database. The object is saved later using thesave
method. The method is synchronous.navigator.contacts.find
: Queries the contacts database and returns an array ofcontact
objects. The method is asynchronous.
Always attach a
deviceready
event first to ensure that Apache Cordova is fully loaded. Thedeviceready
event fires when Apache Cordova is fully loaded. After thedeviceready
has fired, you can safely attach other events.
For more implementation details, review [main.js](contacts sample/scripts/main.js) and the code comments inside.
You can clone this sample in Telerik AppBuilder, explore and modify the code, and build and run it on Android, iOS and Windows Phone 8 devices.
- In your browser, verify that you are logged in the Telerik Platform and you have switched to the account in which you want to develop your application.
- In the account dashboard, click the workspace in which you want to develop your application.
- Click Create project.
- Select AppBuilder Hybrid project.
- Select Start from sample project.
- Select Core APIs.
- Select Contacts.
- (Optional) Rename the project.
- (Optional) Update the description.
- Click Create Project.
- Verify that the AppBuilder Windows client is running and you are logged in the Telerik Platform in the account in which you want to develop your application.
- In the dashboard, click Samples and select Hybrid.
- From the App drop-down menu, select the workspace in which you want to develop your application.
- Select Core APIs.
- Select Contacts.
- (Optional) Rename the project.
- Click Clone.
- Select AppBuilder → Get Sample.
- Select Hybrid.
- Select Core APIs.
- Select Contacts.
- (Optional) Rename the project.
- Click Get.
The extension for Visual Studio copies the sample files locally. The extension creates a new solution and project and loads them.
-
To list the available samples, run the following command.
appbuilder sample
-
Run the clone command for the sample as listed by
appbuilder sample
.appbuilder sample clone contacts
The AppBuilder command-line interface shows the following message: Successfully initialized project in the folder!
With Telerik AppBuilder, you can deploy apps in the device simulator and on device wirelessly or via cable connection. For more information about running apps, see Running Your App.
To test the LiveSync JavaScript API sample, choose one of the following deployment methods.
- Build your project for the companion app and deploy it via QR code.
- Build your project as an application package with the Debug build configuration.
This sample is licensed under the Apache License, Version 2.0. For more information, see License.