{"id":58542,"date":"2023-09-20T19:43:48","date_gmt":"2023-09-20T14:13:48","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=58542"},"modified":"2023-10-05T19:48:04","modified_gmt":"2023-10-05T14:18:04","slug":"what-are-the-local-storage-options-in-the-roku-application","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/what-are-the-local-storage-options-in-the-roku-application\/","title":{"rendered":"What are the local storage options in the Roku Application?"},"content":{"rendered":"<p>What are the local storage options in Brightscript?<\/p>\n<p>What is the Roku or Brightscript FileSystem?<\/p>\n<p>In Roku Application Development, there are a total of 5 local storage options available.<\/p>\n<h2><b>Cachefs:<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">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.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">However, it&#8217;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&#8217;s advisable for a channel to consistently verify the presence of the file it has written to prior to relying on the data cache.<\/span><\/p>\n<h2><b>Tmp:\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The &#8216;tmp&#8217; directory serves as the temporary file storage location for the application, allowing developers to perform read and write operations on it.<\/span><\/p>\n<h2><b>Pkg:<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The root directory of the application grants read-only access to files included in the package (pkg).<\/span><\/p>\n<h2><b>Common:\u00a0<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">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.<\/span><\/p>\n<h2><b>External Storage(USB):<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">The developer can read files from USB devices, and its supported by certain Roku Models only.<\/span><\/p>\n<p><b>Note:\u00a0<\/b><\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">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.<\/span><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<ul>\n<li><span style=\"font-weight: 400;\">The filename components in a pathname must not contain any of these(<\/span><span style=\"font-weight: 400;\"> &lt;\u00a0 &gt;\u00a0 :\u00a0 &#8221;\u00a0 \/\u00a0 |\u00a0 ?\u00a0 *<\/span><span style=\"font-weight: 400;\">) characters.<\/span><\/li>\n<\/ul>\n<h2><b>Code example:\u00a0<\/b><\/h2>\n<pre><span style=\"font-weight: 400;\">theme.OverhangSliceSD = \"pkg:\/images\/Overhang_Slice_SD43.png\"<\/span>\r\n<span style=\"font-weight: 400;\">http.Http.GetToFile(\"tmp:\/categorylist\")<\/span>\r\n<span style=\"font-weight: 400;\">DeleteFile(\"tmp:\/categorylist\")<\/span>\r\n<span style=\"font-weight: 400;\">obj.SetCertificatesFile(\"common:\/certs\/ca-bundle.crt\")<\/span><\/pre>\n<p><b>File Storage comparison:\u00a0<\/b><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Storage<\/b><\/td>\n<td><b>Advantages<\/b><\/td>\n<td><b>Disadvantages<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">tmp:<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Files are read\/write<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Contents are not retained when the application exits<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">cachefs:<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Files are read\/write; an arbitrary amount of data can be written.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">cachefs use is per developer ID. Files in cachefs are stored in RAM; therefore, a reboot will evict them from cachefs.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Data is evicted when more space is required for another Channel<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">pkg:<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Accesses any files included in app package<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Files are read-only<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">file on USB device<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Accesses files on removable USB media<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Files are read-only; not all Roku models support USB<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Registry<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Data is read\/write; data is retained when the application exits and when the system reboots<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Data size is limited. Each channel has access to only 16kb of registry space.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span style=\"text-decoration: underline;\"><strong>ifFileSystem interface functions:\u00a0<\/strong><\/span><\/h2>\n<h3><b>\u25cf GetVolumeList() as Object<\/b><\/h3>\n<h4><b>Description: <\/b><span style=\"font-weight: 400;\">Returns the available volumes on the device.<\/span><\/h4>\n<h4><b>Return Value: <\/b><span style=\"font-weight: 400;\">An <\/span><a href=\"https:\/\/developer.roku.com\/docs\/references\/brightscript\/components\/rolist.md\"><span style=\"font-weight: 400;\">roList<\/span><\/a><span style=\"font-weight: 400;\"> containing strings representing the available volumes.<\/span><\/h4>\n<h3><b>\u25cf GetDirectoryListing(dirPath as String) as Object<\/b><\/h3>\n<h4><strong>Description: <\/strong><span style=\"font-weight: 400;\">Returns the file names in the specified directory path.<\/span><\/h4>\n<h4><strong>Parameters<\/strong><\/h4>\n<table>\n<tbody>\n<tr>\n<td><span style=\"font-weight: 400;\">Name<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Type<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Description<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">dirPath<\/span><\/td>\n<td><span style=\"font-weight: 400;\">String<\/span><\/td>\n<td><span style=\"font-weight: 400;\">The directory path from which to get a list of file names.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><span style=\"font-weight: 400;\"><strong>Return Value<\/strong>: <\/span><span style=\"font-weight: 400;\">An <\/span><a href=\"https:\/\/developer.roku.com\/docs\/references\/brightscript\/components\/rolist.md\"><span style=\"font-weight: 400;\">roList<\/span><\/a><span style=\"font-weight: 400;\"> of strings representing the directory listing of names in dirPath.<\/span><\/h4>\n<h3><b>\u25cf Find(dirPath as String, regEx as String) as Object<\/b><\/h3>\n<h4><strong>Description: <\/strong><span style=\"font-weight: 400;\">Returns the file names in the specified directory path matching the provided regex.<\/span><\/h4>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1375,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":106},"categories":[3477],"tags":[4479,3474],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58542"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1375"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=58542"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58542\/revisions"}],"predecessor-version":[{"id":59085,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/58542\/revisions\/59085"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=58542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=58542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=58542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}