public class

ContactDatabase

extends Object
java.lang.Object
   ↳ com.neomades.contact.ContactDatabase

Class Overview

This class allows to manage contacts in the phone's address book through requests to the data layer.
To use this class, the WRITE_CONTACTS, READ_CONTACTS and GET_ACCOUNTS permissions must be declared in the URS file.

Get this object by calling the static method getDefault().

Summary

Public Methods
void delete(Contact contact, ContactResultListener resultListener)
Deletes a given contact in the phone's address book.
void getAllContacts(ContactResultListener resultListener)
Returns all contacts from the phone's address book.
static ContactDatabase getDefault()
Returns the default instance of ContactDatabase.
void save(Contact contact, ContactResultListener resultListener)
Creates or updates a given contact in the phone's address book.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void delete (Contact contact, ContactResultListener resultListener)

Deletes a given contact in the phone's address book.

Parameters
contact a Contact object to delete. If Contact object is null, it does nothing.
resultListener callback to listen result of contact deletion (can be null)

public void getAllContacts (ContactResultListener resultListener)

Returns all contacts from the phone's address book. The contacts can be accessed with a ContactResultListener.

Parameters
resultListener callback to listen result of contacts

public static ContactDatabase getDefault ()

Returns the default instance of ContactDatabase.

Returns
  • the default instance of ContactDatabase
Throws
SecurityException if one of the three permissions to access contacts (WRITE_CONTACTS, READ_CONTACTS or GET_ACCOUNTS) is missing.

public void save (Contact contact, ContactResultListener resultListener)

Creates or updates a given contact in the phone's address book.
Set the contact's ID with setId(int) method for update an existing contact (or use pickSingleContact(ContactResultListener) to select it).

Parameters
contact a Contact object to save. If Contact object is null, it does nothing.
resultListener callback to listen result of contact creation (can be null)