Import a calendar entry

  1. Import the required classes and interfaces.
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import javax.microedition.pim.Event;
    import javax.microedition.pim.EventList;
    import javax.microedition.pim.PIM;
    
  2. Invoke PIM.getInstance().fromSerialFormat() to return an array of PIMItem objects.
  3. Invoke EventList.importEvent() to add a new calendar entry.
    // Convert an existing entry into a iCal and then 
    // import the iCal as a new entry
    String[] dataFormats = PIM.supportedSerialFormats();
    
    // Write entry to iCal
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    PIM.getInstance().toSerialFormat(event, os, "UTF8", dataFormats[0]);
    
    // Import entry from iCal
    ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
    PIMItem[] pi = PIM.getInstance().fromSerialFormat(is, "UTF8");
    EventList eventList = 
       (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
    Event event2 = eventList.importEvent((Event)pi[0]);
Previous topic: Export a calendar entry

Was this information helpful? Send us your comments.