Blackberry JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE Integration Manual page 36

Blackberry device applications integration guide
Table of Contents

Advertisement

BlackBerry Device Applications Integration Guide
Task
Retrieve contact information.
Select a contact from the address book.
36
Steps
PIMList.items()
1. Invoke
2. Perform one of the following actions:
• To retrieve an array of IDs for fields that have data for a particular contact, invoke
PIMItem.getFields()
• To retrieve the field values, invoke
PIMList.items()
3. When you invoke
list, your BlackBerry® Java® Application must sort items as necessary.
ContactList contactList =
(ContactList)PIM.getInstance().openPIMList(
PIM.CONTACT_LIST, PIM.READ_WRITE);
Enumeration enum = contactList.items();
while (enum.hasMoreElements()) {
Contact c = (Contact)enum.nextElement();
int[] fieldIds = c.getFields();
int id;
for(int index = 0; index < fieldIds.length; ++index) {
id = fieldIds[index];
if(c.getPIMList().getFieldDataType(id) == Contact.STRING) {
for(int j=0; j < c.countValues(id); ++j) {
String value = c.getString(id, j);
System.out.println(c.getPIMList().getFieldLabel(id) + "=" +
value);
}
}
}
}
BlackBerryContactList.choose()
>
Invoke the
BlackBerryGroupContact
BlackBerryContactList list =
(BlackBerryContactList)PIM.getInstance().openPIMList(PIM.CONTACT_
LIST, PIM.READ_WRITE);
PIMItem item = list.choose();
if (item instanceof Contact) {
Contact contact = (Contact)item;
String email = contact.getString(Contact.EMAIL, 0);
System.out.println("Name is: " + email);
}
else if (item instanceof BlackBerryContactGroup) {
...
}
.
.
PIMItem.getString()
to retrieve an enumeration of items in a contacts
to return a
PIMItem.
.
Contact
or

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment 4.6.0

Table of Contents