What are the local storage options in the Roku Application?
What are the local storage options in Brightscript?
What is the Roku or Brightscript FileSystem?
In Roku Application Development, there are a total of 5 local storage options available.
Cachefs:
Cachefs serves as a means to locally store data on Roku Devices, functioning as a read/write file system. For added data persistence, end-users have the option to employ an external SD card with their Roku device. Even users lacking extended storage can enjoy the advantages of a shared in-memory cache, which the system autonomously manages to prioritize recently accessed assets.
However, it’s important to be aware that the operating system retains the authority to remove data at any given time, particularly when another channel generates substantial data, necessitating additional space. Consequently, it’s advisable for a channel to consistently verify the presence of the file it has written to prior to relying on the data cache.
Tmp:
The ‘tmp’ directory serves as the temporary file storage location for the application, allowing developers to perform read and write operations on it.
Pkg:
The root directory of the application grants read-only access to files included in the package (pkg).
Common:
All plugins share access to a shared read-only filesystem. At present, this filesystem exclusively holds a CA certificate bundle, which comprises CA certificates trusted by Firefox (common:/certs/ca-bundle.crt). We strongly recommend utilizing this file in your applications, particularly if you are aggregating multiple distinct data sources.
External Storage(USB):
The developer can read files from USB devices, and its supported by certain Roku Models only.
Note:
-
- There is no notion of a current working directory or relative paths. All path names must adhere to the absolute Roku Streaming Player Pathname format provided above.
- The filename components in a pathname must not contain any of these( < > : ” / | ? *) characters.
Code example:
theme.OverhangSliceSD = "pkg:/images/Overhang_Slice_SD43.png" http.Http.GetToFile("tmp:/categorylist") DeleteFile("tmp:/categorylist") obj.SetCertificatesFile("common:/certs/ca-bundle.crt")
File Storage comparison:
Storage | Advantages | Disadvantages |
tmp: | Files are read/write | Contents are not retained when the application exits |
cachefs: | Files are read/write; an arbitrary amount of data can be written.
cachefs use is per developer ID. Files in cachefs are stored in RAM; therefore, a reboot will evict them from cachefs. |
Data is evicted when more space is required for another Channel |
pkg: | Accesses any files included in app package | Files are read-only |
file on USB device | Accesses files on removable USB media | Files are read-only; not all Roku models support USB |
Registry | Data is read/write; data is retained when the application exits and when the system reboots | Data size is limited. Each channel has access to only 16kb of registry space. |
ifFileSystem interface functions:
● GetVolumeList() as Object
Description: Returns the available volumes on the device.
Return Value: An roList containing strings representing the available volumes.
● GetDirectoryListing(dirPath as String) as Object
Description: Returns the file names in the specified directory path.
Parameters
Name | Type | Description |
dirPath | String | The directory path from which to get a list of file names. |