×
Namespaces

Variants
Actions
Revision as of 16:25, 3 June 2009 by jarmlaht (Talk | contribs)

How to list the supported fields in a PIMList

From Nokia Developer Wiki
Jump to: navigation, search

Overview

When using PIM API and its PIMList class, it is important to find out first, what fields are supported by the implementation. This can be done by using the following kind of method:

private void readSupportedFields() {
System.out.println("EventList contents:");
try {
String[] lists = PIM.getInstance().listPIMLists(PIM.EVENT_LIST);
int length = lists.length;
EventList[] eventList = new EventList[length];
for (int i = 0; i < length; i++) {
eventList[i] = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE, lists[i]);
System.out.println(i+1+": "+lists[i]);
int[] fields = eventList[i].getSupportedFields();
System.out.println("Supported fields:");
for (int j = 0; j < fields.length-1; j++) {
System.out.println(fields[j]+" ");
}
}
} catch (PIMException pe) {
// no such list
} catch (SecurityException se) {
// MIDlet is not allowed to access to the specified list
}
}

If you need to know the supported fields in contact list or to-do list, just replace PIM.EVENT_LIST with PIM.CONTACT_LIST or PIM.TODO_LIST. Note, that you will get only the constant values of the fields, so output might look like this: 1: Meeting Supported fields: 108 107 100 106 102. The actual field names can be found from PIM API specification.

See also

37 page views in the last 30 days.
×