Previously, we looked at serverStorage, which allows you to save data from your app on the Volt server instead of on the device. serverStorage is saved for the user of the app – other users cannot look at it.
appStorage is data which is shared by all the users of the app. Some possible uses are:
- A product list, with the latest prices and availability.
- A message to all users.
- A table with the latest tax rates or exchange rates.
appStorage works just like serverStorage. It has the same functions. The big differences are that all users of the app see the exact same data, and only Dashboard apps can modify it.
Regular users of the app can use getItem() and getAllItems.
The function clear(), removeItem() and setItem() can be used if the following two conditions are met:
- Dashboard Access in Project Properties is set to true.
- The name used to sign into the app is the same as the name used to upload the app to Volt.
To use these functions, there is an additional 3rd parameter with the VoltID of the app whose appStorage is to be changed:
appStorage.setItem("SimpleString", "ABCD", "XxXxXx", done);
Dashboard apps include the Dashboard itself, as well as apps which have Volt Dashboard Access project property set to True. You can check NSB.voltDashboardAccess at runtime to see if Dashboard access is enabled.
This is a powerful features, but it should be used wisely. Set Volt Dashboard Access to false for your users so they only read the data in appStorage. If you have an app which creates and changes data for them, do so in a separate app with Volt Dashboard Access set to true.