Export a task

  1. Import the required classes and interfaces.
    import java.io.ByteArrayOutputStream;
    import java.util.Enumeration;
    import javax.microedition.pim.PIM;
    import javax.microedition.pim.ToDo;
    import javax.microedition.pim.ToDoList;
    
  2. Use an output stream writer to export tasks from the BlackBerry® device to a supported serial format.
  3. To retrieve a string array of supported serial formats, invoke PIM.supportedSerialFormats(), and then specify the list type (PIM.TODO_List).
  4. To write an item to a serial format, invoke PIM.getInstance().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.
    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]);
    }
Next topic: Import a task

Was this information helpful? Send us your comments.