Here is an overview of the BlackBerry® PlayBook™ application sandbox file system layout for the latest release 0.9.2
Applications will be run in the directory we call "sandbox". Name of this directory is irrelevant and cannot be relied on. An application should not attempt to access any files outside of this directory. Sandbox is the default "working directory".
The structure is
All except shared are app's private directories, only the app can read/write files there.
The "app" directory is the link to where application files are installed (what was packaged in the bar file), these files are read only. For Adobe® AIR®, application files will be in subdirectory "air" (i.e. app/air/your_file).
The private data directory is "data". Application has full access to this directory (read/write). The $HOME env var is set to this directory. To initiate the sandbox app may copy files from "app" to "data" (for example user modifiable config files) on the first run.
The "tmp" directory can be used to create temporary files, application should take care of cleaning these files, but system may remove them at any time app is not running - so it cannot be used to persist data, only "data" directory should be used for this.
The "logs" is used for development, application stdin and stdout is redirected to logs/log file, as well as "core" files will be created there if app crashes.
The "shared" is link to common location where all apps share files. It has the following structure:
| Alias | Path |
|---|---|
| File.applicationDirectory | (appname)/app/air |
| File.applicationStorageDirectory | (appname)/data |
| File.desktopDirectory | (appname)/shared/documents |
| File.documentsDirectory | (appname)/shared/documents |
| File.userDirectory | (appname)/ |
Best practices for application data storage
Even though the file structure within the application's sandbox is predefined, it does have implications on the application's data when it is uninstalled from the device. Data that is stored in any sandbox subdirectories by the application is deleted when the application is uninstalled, with the exception of data stored within the shared directory. Moreover. if data is stored in the shared directory with a '.' prefixed to the name, the OS treats the data as a hidden file. Also, the chance of filename collisions increase among applications that write to the same shared file space.
It is recommended that applications persist data in their own application storage directory (i.e. data or tmp subdirectory), instead of storing the data within the shared subdirectory. Note that the data does not get removed within the application's data directory when the application is upgraded to a newer version.