Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.0.5 for Windows
  Go To Table Of Contents
Go To Index


16 JSR 75: PDA Optional Packages

The Java ME SDK supports JSR 75, the PDA Optional Packages (PDAP) for the J2ME Platform. JSR 75 includes two independent APIs:

This chapter describes how the Java ME SDK implements the FileConnection and PIM APIs.

16.1 FileConnection API

On a real device, the FileConnection API typically provides access to files stored in the device's memory or on a memory card.

In the Java ME SDK emulator, the FileConnection API enables MIDlets to access files stored on your computer's hard disk.

The files that can be accessed using the FileConnection optional package are stored in the following subdirectory:

Documents and Settings\user\javame-sdk\3.0.5\work\emulator-instance\appdb\filesystem

For example, the DefaultCldcPhone1 emulator instance comes with a root directory installed called root1, which contains a Readme file and an empty directory named photos.

Each subdirectory of filesystem is called a root. The Java ME SDK provides a mechanism for managing roots. While the emulator is running, choose Device > File Connection. The opens with the File Connection tab selected.

In the File Connection panel you can mount, unmount, or delete filesystem roots. Mounted roots are displayed in the top list, and unmounted roots are moved to the bottom list. Mounted root directories and their subdirectories are available to applications using the FileConnection API. Unmounted roots can be remounted in the future.

16.2 PIM API

The Java ME SDK emulator stores contact, calendar, and to-do information in standard files on your desktop computer's hard disk. All information is stored in:

Documents and Settings\user\javame-sdk\3.0.5\work\emulator-instance\appdb\PIM

Each device instance has its own data. Lists are stored in subdirectories of the contacts, events, and todo directories. For example, a contact list called Contacts is contained in \appdb\PIM\Contacts:

Inside the list directory, items are stored in vCard (.vcs) or vCalendar (.vcf) format (see Contacts are stored in vCard format, while calendar and to-do items are both stored in vCalendar format.

16.3 Running PDAPDemo

PDAPDemo shows how to use the PIM and FileConnection APIs that are part of the JSR 75 specification.

16.3.1 Browsing Files

To run the file browser, you'll need to give the MIDlet appropriate security authorization, if you have not already done so. Right-click on your project, choose Properties, and select Specify the Security Domain. If necessary, select the maximum domain and press OK.

Now open and run the PDAPDemo project. Launch the FileBrowser MIDlet. You see a directory listing, and you can browse through the available directories and files. By default there is one directory, root1. This directory is located at:

Documents and Settings\user\javame-sdk\version\work\instance\appdb\filesystem\root1

Description of pdap-root1.gif follows
Description of the illustration pdap-root1.gif

Select the directory and press the View soft button to enter it.

The directories photos and private are empty by default. You can add files and root directories and they will be visible to the JSR 75 File API. (This demo shows a README and some JPEGs that were added to the local photos directory.)

Description of pdap-dirs.gif follows
Description of the illustration pdap-dirs.gif

Using the Menu commands you can view a file or see its properties. Try selecting the file and choosing Properties or View from the menu.

16.3.2 The PIM API

The JSR75 PIM APIs example demonstrates how to access personal information, like contact lists, calendars, and to-do lists. After you launch the example, choose a type of list from the main menu.

In this example application, each type of list works the same way and each list type contains a single list. For example, if you choose Contact Lists, there is a single contact list called Contacts. Event Lists contains a single list called Events, and To Do Lists contains a single list named To Do.

Description of pdap-demo-listtype.gif follows
Description of the illustration pdap-demo-listtype.gif

Once you've selected a list type and chosen the specific list, you can view all the items in the list. If this is the first time you've run the example, the list is probably empty.

To add an item, choose New from the menu. The application prompts you for a Formatted Name for the item. You can add more data fields to this item using option 3, Add Field, in the menu. You see a list of field names. Pick as many as you like. You can fill in the field at any time.

Description of pdap-demo-newcontact.gif follows
Description of the illustration pdap-demo-newcontact.gif

To save the list item, choose Commit (option 5) from the menu.

To return to the list, choose the Back command. You'll see the item you just created in the list.

The items that you create are stored in standard vCard or vCalendar format in the device\pim directory.

The PIM API allows for exporting contact, calender, and to-do items in a standard format. The exact format depends on the list type. When you are viewing an item in any list, the menu contains a command for viewing the exported item.

For example, when you are viewing a contact list item, the menu contains Show vCard. When you choose this command, the exported item is shown on the screen. Calendar items and to-do items both get exported as vCalendar.