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

Blackberry device applications integration guide
Table of Contents

Advertisement

BlackBerry Device Applications Integration Guide
Task
Export a task.
Import a task.
Delete a task.
Close a task list.
42
Steps
1. To import or export PIM item data, use an output stream writer to export tasks from the
BlackBerry® device to a supported serial format.
2. To retrieve a string array of supported serial formats, invoke
PIM.supportedSerialFormats()
3. To write an item to a serial format, invoke
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.
ToDoList todoList = (ToDoList)PIM.getInstance().openPIMList(
PIM.TODO_LIST, PIM.READ_ONLY);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
String[] dataFormats =
PIM.getInstance().supportedSerialFormats(PIM.TODO_LIST);
Enumeration e = todoList.items();
while (e.hasMoreElements()) {
ToDo task = (ToDo)e.nextElement();
PIM.getInstance().toSerialFormat(task, byteStream, "UTF8",
dataFormats[0]);
}
PIMItem
1. To return an array of
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.
2. To create a new task using the PIM items, invoke
importToDo()
method saves the task; you do not have to invoke
String[] dataFormats = PIM.toDoSerialFormats();
// Write task to serial format.
ByteArrayOutputStream os = new ByteArrayOutputStream();
PIM.getInstance().toSerialFormat(task, os, "UTF8", dataFormats[0]);
// Import task from serial format.
ByteArrayInputStream is = new
ByteArrayInputStream(outputStream.toByteArray());
PIMItem[] pi = PIM.getInstance().fromSerialFormat(is, "UTF8");
ToDoList todoList = (ToDoList)PIM.getInstance().openPIMList(
PIM.TODO_LIST, PIM.READ_WRITE);
ToDo task2 = todoList.importToDo((ToDo)pi[0]);
removeToDo()
>
Invoke
on a task list.
todoList.removeToDo(task);
todoList.close()
1. Invoke
2. Create code that manages exceptions.
try {
todoList.close();
} catch (PimException e) {
// Handle exception.
}
, and then specify the list type (
toSerialFormat(
fromSerialFormat()
objects, invoke
ToDoList.importToDo()
.
PIM.TODO_List
).
). The enc parameter specifies the
. The enc parameter
. The
commit()
.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Java development environment 4.6.0

Table of Contents