Java Reference
In-Depth Information
The birthday of a contact can be set as shown in the following line of code:
myContact.setDate(Contact.BIRTHDAY, new Date());
Binary Data
Another simple field type is the byte array that can be added to a contact, for instance to store a photo
of a person in a Contact object. Analogous to the string and date fields, methods for setting and
retrieving the contents of that field are provided. The only supported field ID for a byte array type is the
predefined PHOTO constant to store a person's photograph.
For setting a byte array, use the setBinary() method, which takes a field ID and the byte array to
be stored in the contact. For retrieving the byte array, use getBinary() , which takes a field ID as
the only parameter.
Multivalue Data
Multivalue fields are used to store multiple instances of the same field. For instance, a field of a
Contact might contain different types (locations) of phone numbers, such as home or work phone
numbers. All phone numbers are stored in the different subentries of the same TEL entry. Typed data is
added to a contact using the set setTypedString() method that takes three parameters: the field
ID, the type ID, and the value to be stored. Revision is a read-only field that is set by the
implementation automatically.
Table 7.2 shows the fields that can take multiple values and the corresponding predefined type IDs.
Table 7.2. Multivalue Contact Fields a nd the Corresponding Type IDs
Field IDs
T ype IDs
EMAIL , FAX , TEL
TYPE_ASSISTANT , TYPE_AUTO ,
TYPE_HOME , TYPE_MOBILE , TYPE_OTHER ,
T YPE_PAGER , TYPE_WORK
ADDR_COUNTRY , ADDR_EXTRA ,
ADDR_LOCALITY , ADDR_POBOX ,
ADDR_POSTALCODE , ADDR_REGION ,
A DDR_STREET
TYPE_HOME , TYPE_OTHER , TYPE_WORK
The following code snippet shows how two phone numbers, the home and work phone number, are
assigned to a contact:
myContact.setTypedString(Contact.TEL, Contact.TYPE_WORK, "555-1177");
myContact.setTypedString(Contact.TEL, Contact.TYPE_HOME, "555-7711");
Device-Specific Meta Information
Because the currently available PDA devices have different native PIM implementations, the
PIMList interface provides query methods for retrieving information about all supported fields and
the supported types for a given field ID.
For obtaining this information, the getSupportedFields() , isFieldSupported() and
getSupportedTypes() methods are provided. The getSupportedFields() method returns
an integer array containing all field IDs that are supported by the device. The method
IsSupportedField() returns a boolean determining whether the given field ID is supported. The
getSupportedTypes() method takes a field ID as a parameter and returns an int array
containing all possible subtypes for this field. For example, you can query the possible type IDs for the
Contact.TEL field of a given ContactList using the following code snippet:
 
Search WWH ::




Custom Search