Java Reference
In-Depth Information
int [] possibleSubTypes =
myContactList.getSupportedTypes(Contact.TEL);
On a device that is capable of storing only a home and a work phone number, the resulting int array
contains the type IDs Contact.TYPE_HOME and Contact.TYPE_WORK only.
Extended Fields
A Contact may also provide support for so-called "extended" fields. Extended fields are supported to
store device-dependent fields, where no field ID is predefined.
The IDs for extended fields are returned by the getSupportedFields() method of the PIMList
interface. They are returned together with the standard fields in the same array. The method
isExtendedField() can be used to determine whether a field is an extended field with a non-
standard ID.
When working with extended fields, two additional methods of the PIMList interface are of special
interest. The method getFieldLabel() returns a human-readable label for a given field ID. This
method allows an application to display a label for an extended field, although the meaning of the ID is
not known to the application. The method PIMElement.getDataType() returns one of the
PIMElement constants STRING , DATE , INT , BINARY , or TYPED_STRING . This method allows
the application to figure out the correct access methods for an extended field.
Categories
Contact s can be assigned to one or more categories using the addToCategory() method. The
method takes the name of the category as String parameter. The maximum number of categories a
contact may be assigned to can be queried using the maxCategories() method. A return value of -
1 means that the number of categories is not limited. A Contact can be removed from a category
using removeFromCategory() .
Please note that devices may limit the category names to those defined in the corresponding PIMList .
If a Contact is added to an invalid category an PIMListException is thrown. PIMList
provides the following methods to manage categories available: addCategory() ,
deleteCategory() , and getCategories() .
ContactList s: Creating, Updating, and Deleting Contact s
Now that you are familiar with the fields of the Contact interface, it is time to take a look at the
ContactList interface, which encapsulates access to the persistent contact database.
The ContactList is derived from the PIMList interface, which offers the base functionality for
handling collections of PIM elements. ContactList provides a createContact() method for
creating new contacts.
When creating new contacts or modifying existing contacts , the commit() method of the Contact
interface must be called in order to make the changes persistent. Without calling commit, a new contact
will not be stored in the database.
The PIMList class supports a deleteElement() method, which takes a PIMElement as a
parameter, can be used to delete the specified element from the database.
The PIMList class also provides two methods for retrieving an enumeration: an elements()
method that returns all elements of the database, and a second elements() method that gets all
Search WWH ::




Custom Search