Export a calendar entry

  1. Import the required classes and interfaces.
    import java.io.ByteArrayOutputStream;
    import java.util.Enumeration;
    import javax.microedition.pim.Event;
    import javax.microedition.pim.EventList;
    import javax.microedition.pim.PIM;
  2. Invoke PIM.supportedSerialFormats() specifying the list type (PIM.EVENT_LIST), to retrieve a string array of supported serial formats.
    String[] dataFormats = PIM.supportedSerialFormats(PIM.EVENT_LIST);
  3. Use an output stream writer to export calendar entries from the BlackBerry® device to a supported serial format, such as iCal.
  4. Invoke toSerialFormat() to write an item in serial format. 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]);

Was this information helpful? Send us your comments.