|Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.2 for Windows
The FileConnection optional package allows MIDlets access to a local device file system.
The Personal Information Management (PIM) optional package includes APIs for manipulating contact lists (address book), calendars, and to-do lists.
This chapter describes how the Oracle Java ME SDK implements the FileConnection and PIM APIs.
In the Oracle 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
For example, the
JavaMEPhone1 emulator instance comes with a root directory installed named
root1. Each subdirectory of
filesystem is called a root. The Oracle Java ME SDK provides a mechanism for managing roots.
While the emulator is running, choose Device > File Connection. The External Events Generator 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.
To add a new empty filesystem root directory, click Mount Empty and fill in a name for the directory.
To mount a copy of an existing directory, click Mount Copy, and browse to choose a directory you want to copy. When the File System Root Entry dialog opens, enter the name for this root. A deep copy of the selected directory is placed into the emulator's filesystem with the specified root name.
To make a directory inaccessible to the FileConnection API, select it in the list and click Unmount. The selected root is unmounted and moved to the Unmounted roots list.
To completely remove a mounted directory, select it and click Unmount & Delete.
To remount an unmounted directory, select it and click Remount. The root is moved to the mounted roots list.
To delete an unmounted directory, select it and click Delete. The selected root is removed from the list.
The Oracle 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
Each device instance has its own data. Lists are stored in subdirectories of the
todo directories. For example, a contact list called Contacts is contained in installdir
Inside the list directory, items are stored in vCard (
.vcf) or vCalendar (
.vcs) format (see
http://www.imc.org/pdi/). Contacts are stored in vCard format, while calendar and to-do items are both stored in vCalendar format.
The default emulators have one directory,
root1. This directory is located at:
For test purposes, copy files or even directories into root1. You can also add other directories at the same level as root1.
Now open and run the
FileBrowser MIDlet. You see a directory listing, and you can browse through the directories and files you have placed there.
Select a directory and press the View soft button to enter it.
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.
You can view the content of text files in the browser.
Try using the External Events Generator to unmount and mount directories. Unmounted directories are not visible in the application running on the emulator.
After you launch the example, choose a type of list from the main menu.
In this example 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.
After you have 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 have run the example, the list might be empty.
To add an item, choose New from the menu. The application prompts you for a Formatted Name for the item.
To add more data fields to this item choose the menu item Add Field. You see a list of field names. Pick as many as you like. You can fill in the fields at any time.
To save the new item, choose Commit 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 this 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.