Storing files in the file system

You can programmatically create and manage the files and folders on BlackBerry smartphones with the FileConnection API. The FileConnection API was introduced with BlackBerry Device Software 4.2.

The FileConnection API is implemented in the javax.microedition.io.file package.

The FileConnection API is defined by JSR 75 and is built on the Generic Connection Framework. The main component of the FileConnection API is the javax.microedition.io.file.FileConnection class. Unlike other Generic Connection Framework connections, FileConnection objects can be successfully returned from the javax.microedition.io.Connector.open() method without referencing an existing file or folder. This behavior allows for the creation of new files and folders on a file system. In addition to RIM documentation, there are many sources of information about JSR 75 and the Generic Connection Framework.

In addition, RIM provides extensions to the FileConnection API. The net.rim.device.api.io.file package includes the following class and interfaces:

You can access the file system on internal storage and external media card storage:

Internal storage

Internal storage is application storage or built-in media storage. All smartphones have internal storage. To access internal storage, use the path file:///store. For example,

FileConnection fc = (FileConnection)Connector.open("file:///Store")

External storage

You can access external media card storage only on smartphones with microSD cards. To access external media card storage, use the path file:///SDCard. For example,

FileConnection fc = (FileConnection)Connector.open("file:///SDCard")

Files created by your app are not automatically deleted when your app is uninstalled.

Devices that have built-in media storage have a file system partition called System. In BlackBerry Device Software 5.0 and later, the system partition is reserved for system use and is read-only. In BlackBerry Device Software versions earlier than 5.0, the system partition is read/write. You can access this partition with the path file:///system.

Previous topic: Access to memory

Was this information helpful? Send us your comments.