Oracle® Java Micro Edition Software Development Kit Developer's Guide Release 8 for Windows E50624-01 |
|
![]() Previous |
![]() Next |
Oracle Java ME SDK 8 supports JSR 75: PDA Optional Packages for the J2ME Platform. JSR 75 includes the FileConnection
optional package that enables IMlets to access a local device's file system.
This chapter describes how Oracle Java ME SDK 8 implements the FileConnection
API.
On an external device, the FileConnection
API typically provides access to files stored in the device's memory or on a memory card.
In the Oracle Java ME SDK 8 emulator, the FileConnection
API enables IMlets 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 device's directory, for example:
userdir\javame-sdk\8.0\work\EmbeddedDevice1\appdb\filesystem
Each subdirectory of filesystem
is called a root. Oracle Java ME SDK 8 provides a mechanism for managing roots in the Java ME Embedded Emulator.
While the emulator is running, open the Tools menu and select Manage File System. In the Manage File System window, you can mount, unmount, or unmount and delete file system roots. Mounted roots are displayed in the top list, and unmounted roots are displayed in the bottom list. You can remount or delete a selected directory. 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 file system root directory, click Mount Empty and enter a name for the directory.
To mount a copy of an existing directory, click Mount Copy and browse to select a directory you want to copy. When the File System Root Entry dialog box opens, specify the name for this root. A deep copy of the selected directory is placed into the emulator's file system 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.
PDAPDemo
shows you how to use the FileConnection
API that is part of the JSR 75 specification.
The default emulators have one directory, root1
. This directory is located at:
username\javame-sdk\8.0\work\
devicename\appdb\filesystem\root1
For test purposes, copy files or directories into the root1
directory of the default emulator. You can also add other directories at the same level as root1
.
Open and run the PDAPDemo
project:
Start the FileBrowser
IMlet. You see a directory listing, and you can browse through the directories and files you placed there.
Select a directory and click the View button to open 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 Java ME Embedded Emulator to unmount and mount directories. Unmounted directories are not visible in the application running on the emulator.