javax.microedition.io.file
Class FileSystemRegistry

java.lang.Object
  extended by javax.microedition.io.file.FileSystemRegistry

public class FileSystemRegistry
extends Object

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.

See Also:
FileConnection, FileSystemListener
Since:
BlackBerry API 4.2.0, FileConnection 1.0

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

addFileSystemListener

public static boolean addFileSystemListener(FileSystemListener listener)
Registers a 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.

Parameters:
listener - The new FileSystemListener that is to be registered in order to handle adding and removing file system roots.
Returns:
true if the file system listener was successfully added; otherwise false.
Throws:
SecurityException - If the application is not given permission to read files.
NullPointerException - If the listener is null.
See Also:
FileSystemListener, FileConnection
Since:
BlackBerry API 4.2.0

removeFileSystemListener

public static boolean removeFileSystemListener(FileSystemListener listener)
Removes a registered FileSystemListener. If file systems are not supported on a device, this method returns false.

Parameters:
listener - The FileSystemListener to be removed.
Returns:
true if the file system listener was successfully added; otherwise false.
Throws:
NullPointerException - If the listener is null.
See Also:
FileSystemListener, FileConnection
Since:
BlackBerry API 4.2.0

listRoots

public static Enumeration listRoots()
Returns the currently mounted root file systems on the device as String objects in an Enumeration. If there are no roots available on the device, a zero length Enumeration is returned. If file systems are not supported on a device, a zero length Enumeration is also returned (this check is performed prior to security checks).

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 ValueOpening 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());
   } 
 

Returns:
An eumeration of mounted file systems as String objects.
Throws:
SecurityException - If the application is not given permission to read files.
See Also:
FileConnection
Since:
BlackBerry API 4.2.0





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