Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 8 for Windows
E50624-01
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

17 JSR 75: PDA Optional Packages

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.

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.

Running PDAPDemo

PDAPDemo shows you how to use the FileConnection API that is part of the JSR 75 specification.

Browsing Files

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.