Search code examples
blackberrycalendarblackberry-jde

How to list the events from native calendar


I am trying to list all the events from a native calendar using the code below. I am getting an object, and I want the exact event string. I have set a meeting in my calendar and I want to read the same.

  private void getEvents() {
                try {       

                          EventList eventList = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_ONLY);

                          Enumeration events = eventList.items()

                          while (events.hasMoreElements()) {



                            Event event = (Event)events.nextElement();



                            Dialog.alert(event.toString());

                          }



                        } catch (PIMException e) {



                          Dialog.alert(e.getMessage());

                        }

        }

I have added a meeting as a event in calendar and i want to read this.


Solution

  • I'm not sure exactly what you want but for example if you wanted to read the subject line you could do something like this:

    if(eventList.isSupportedField(BlackBerryEvent.SUMMARY) && event.countValues(BlackBerryEvent.SUMMARY) > 0) {
        subject = event.getString(BlackBerryEvent.SUMMARY, 0); 
    }