36
BlackBerry Device Applications Integration Guide
Retrieve contact information.
1.
Invoke
PIMList.items()
.
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
PIMItem.getString()
.
3. When you invoke
PIMList.items()
to retrieve an enumeration of items in a contacts
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);
}
}
}
}
Select a contact from the address book.
>
Invoke the
BlackBerryContactList.choose()
to return a
Contact
or
BlackBerryGroupContact
PIMItem.
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) {
...
}
Task
Steps
Содержание JAVA DEVELOPMENT ENVIRONMENT - - DEVICE APPLICATIONS INTEGRATION - DEVELOPMENT GUIDE
Страница 1: ...BlackBerry Java Development Environment Version 4 6 0 BlackBerry Device Applications Integration Guide...
Страница 4: ......
Страница 7: ......
Страница 10: ...10 BlackBerry Device Applications Integration Guide...
Страница 12: ...12 BlackBerry Device Applications Integration Guide...
Страница 50: ...50 BlackBerry Device Applications Integration Guide...
Страница 56: ...56 BlackBerry Device Applications Integration Guide...
Страница 65: ......
Страница 66: ...2008 Research In Motion Limited Published in Canada...