BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-03-2006, 11:27 AM   #1
smudboy
New Member
 
Join Date: Jul 2006
Model: 7520
Posts: 11
Default Calendar Access

Please Login to Remove!

I'm trying to retrieve data from the Calendar system (that is, appointments), and I've been using the example from the Developers Guide Volume 2. In it lists:

Code:
EventList eventList = (EventList)PIM.getInstance().openPIMList(
PIM.EVENT_LIST, PIM.READ_ONLY);
Enumeration e = eventList.items();
while (e.hasMoreElements())

Event event = (Event)e.nextElement();
int[] fieldIds = event.getFields();
int id;
for(int index = 0; index < fieldIds.length; ++index) {
id = fieldIds[index];
if(e.getPIMList().getFieldDataType(id) == STRING) {
for(int j=0; j < event.countValues(id); ++j) {
String value = event.getString(id, j);
System.out.println(event.getFieldLable(id) + "=" + value);
}
}
}
Which has a few errors.

I've fixed it so it works:

Code:
       EventList eventList = null;
        Event event = null;
        Enumeration myEnum = null;
        int[] fieldIds = null;
        int id =0;
        String value = null;
        try {
            eventList = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_ONLY);
            myEnum = eventList.items();
            //Dialog.alert(myEnum.toString());
            while (myEnum.hasMoreElements()) {
                event = (Event)myEnum.nextElement();
                fieldIds = event.getFields();
                for(int index = 0; index < fieldIds.length; ++index) 
                {
                    id = fieldIds[index];
                        for(int j=0; j < event.countValues(id); ++j) 
                        {
                            value = event.getString(id, j);
                            Dialog.alert("=" + value);
                        }
               }
            }
        } catch (Exception e) {/* handle exception */}
However, after putting in multiple appointments, it only seems to bring back one appointment -- always the same one in the middle of the month (as opposed to appointments further down the month, closer to today, and those in other months.) Very weird! I'm trying to list all the appointments in a list and then have the user select them and their data...any ways of how to do this?

Thanks.
Offline  
Old 08-03-2006, 11:48 AM   #2
smudboy
New Member
 
Join Date: Jul 2006
Model: 7520
Posts: 11
Default It finds the first one created...

The loop seems to find the first one created, then the next...since I deleted the first.

But it still breaks out of the loop when it's listed all its contents of its first appointment.
Offline  
Old 08-03-2006, 02:33 PM   #3
fbrimm
Thumbs Must Hurt
 
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Default

smudboy,

Have you tried using the debugger to see what your enumeration (myEnum) of the eventList contains?

Is it ending because of an Exception?

fbrimm
Offline  
Old 08-03-2006, 04:16 PM   #4
smudboy
New Member
 
Join Date: Jul 2006
Model: 7520
Posts: 11
Default

Yeah, there were a few exceptions.

The code relies on the line:
Code:
if(event.getPIMList().getFieldDataType(id) == PIMItem.STRING) {

...
Which I mistakenly took away. It works fine now. So far, I've found that the EventList object only returns PIMItem of type STRING, INT, BOOLEAN & DATE. I'm working in 4.1, so the calendar option allows you to set a "Show Time As" field from "Free, Tentative, Busy, Out of Office." However, on the 4.0 BBs, there is no option. Although, if you sync it up with your PC/Outlook, on your PC it will set all those fields to Busy. Interestingly enough on 4.1, if you don't change the Busy status, or switch back to Busy status, the entire Field (which eventList.getFieldLabel(id).toString() returns as "" btw) gets removed. As such, it's a no name INT field whose values are Free=0, Tentative=1 and Out of Office=2.

Quirky stuff eh?
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


APPLE 630-0895-B  VRAM 128K X 8 BOARD CARD VINTAGE picture

APPLE 630-0895-B VRAM 128K X 8 BOARD CARD VINTAGE

$74.77



APPLE 820-0522-A 630-0895-B LITE VRAM 128K X 8 BOARD  picture

APPLE 820-0522-A 630-0895-B LITE VRAM 128K X 8 BOARD

$149.99



128K RAM - APPLE - ORIGINAL APPLE prototype BOARD picture

128K RAM - APPLE - ORIGINAL APPLE prototype BOARD

$408.75







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.