Storing files in the file system

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

The File Connection API is implemented in the package.

The File Connection API is defined by JSR 75 and is built on the Generic Connection Framework. The main component of the File Connection API is the class. Unlike other Generic Connection Framework connections, FileConnection objects can be successfully returned from the 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 File Connection API. The 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 BlackBerry smartphones have internal storage. To access internal storage, use the path file:///store. For example,

FileConnection fc = (FileConnection)"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)"file:///SDCard")

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

Smartphones that have built-in media storage have a file system partition called System. You can access this partition with the path file:///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.

Was this information helpful? Send us your comments.