Troubleshooting guide
166
BlackBerry Java Development Environment Development Guide
Save an appointment. To save an appointment, use the importEvent() method; you do not have to invoke commit().
1. Before you save the appointment, to identify appointment fields that have changed since the
appointment was last saved, invoke i
sModified().
2. Invoke commit().
if(event.isModified()) {
event.commit();
}
Retrieve appointment information. 1. To retrieve an enumeration of appointments, invoke PIMList.items().
EventList eventList = (EventList)PIM.getInstance().openPIMList(
PIM.EVENT_LIST, PIM.READ_ONLY);
Enumeration e = eventList.items();
2. To retrieve an array of IDs of fields that have data for a particular task, invoke
PIMItem.getFields().
3. To retrieve the field values, invoke PIMItem.getString().
while (e.hasMoreElements()) {
Event event = (Event)e.nextElement();
int[] fieldIds = event.getFields();
int id;
for(int index = 0; index < fieldIds.length; ++index) {
id = fieldIds[index];
if(e.getPIMList().getFieldDataType(id) == STRING) {
for(int j=0; j < event.countValues(id); ++j) {
String value = event.getString(id, j);
System.out.println(event.getFieldLable(id) + "=" + value);
}
}
}
}
Export an appointment. 1. To import or export PIM data, use an output stream writer to export tasks from the BlackBerry
device to a supported serial format, such as iCal®.
2. To retrieve a string array of supported serial formats, invoke
PIM.supportedSerialFormats()
, and then specify the list type (PIM.EVENT_List).
3. To write an item in serial format, invoke toSerialFormat(). The enc parameter specifies the
character encoding to use when writing to the output stream. Supported character encodings
include “UTF8,” “ISO-8859-1,” and “UTF-16BE.” This parameter cannot be null.
EventList eventList = (EventList)PIM.getInstance().openPIMList(
PIM.EVENT_LIST, PIM.READ_ONLY );
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
Enumeration e = eventList.items();
while (e.hasMoreElements()) {
Event event = (Event)e.nextElement();
PIM.getInstance().toSerialFormat(event, byteStream, "UTF8",
dataFormats[0]);
}
Task Steps