|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.io.file.FileSystemRegistry
public class FileSystemRegistry
The FileSystemRegistry is a central registry for file system listeners interested in adding and removing (or mounting and unmounting) the file systems on a device.
FileConnection
,
FileSystemListener
Method Summary | ||
---|---|---|
static boolean |
addFileSystemListener(FileSystemListener listener)
Registers a FileSystemListener that is
notified when adding and removing a new file system root. |
|
static Enumeration |
listRoots()
Returns the currently mounted root file systems on the device as String objects in an Enumeration. |
|
static boolean |
removeFileSystemListener(FileSystemListener listener)
Removes a registered FileSystemListener . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean addFileSystemListener(FileSystemListener listener)
FileSystemListener
that is
notified when adding and removing a new file system root.
Multiple file system listeners can be added. If file
systems are not supported on a device, the method returns false
. This check
is performed prior to security checks.
listener
- The new FileSystemListener
that is to be registered in
order to handle adding and removing file system roots.
true
if the file system listener was successfully
added; otherwise false
.
SecurityException
- If the application is not given permission
to read files.
NullPointerException
- If the listener is null
.FileSystemListener
,
FileConnection
public static boolean removeFileSystemListener(FileSystemListener listener)
FileSystemListener
. If file
systems are not supported on a device,
this method returns false
.
listener
- The FileSystemListener
to be removed.
true
if the file system listener was successfully
added; otherwise false
.
NullPointerException
- If the listener is null
.FileSystemListener
,
FileConnection
public static Enumeration listRoots()
The first directory in the file URI is referred to as the root, which corresponds to a logical mount point for a particular storage unit of memory. Root strings are defined by the platform or implementation and can be a string of zero or more characters ("" can be a valid root string on some systems) followed by a trailing forward slash (/) to denote that the root is a directory. Each root string is guaranteed to uniquely refer to a root. Root names are device specific and are not required to adhere to any standard. Following are examples of possible root strings and how to open them:
Root Value | Opening the Root |
---|---|
CFCard/ | Connector.open("file:///CFCard/"); |
SDCard/ | Connector.open("file:///SDCard/"); |
MemoryStick/ | Connector.open("file:///MemoryStick/"); |
C:/ | Connector.open("file:///C:/"); |
/ | Connector.open("file:////"); |
The following example shows the use of listRoot
to retrieve
the available size of all roots on a device:
Enumeration rootEnum = FileSystemRegistry.listRoots(); while (e.hasMoreElements()) { String root = (String) e.nextElement(); FileConnection fc = Connector.open("file:///" + root); System.out.println(fc.availableSize()); }
SecurityException
- If the application is not given permission
to read files.FileConnection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal