Best practice for persistent storage? #2321
-
I've gotten a feature request that would require storing some persistent data. It looks like most of that is done through the Settings controller. The data I'm looking to store is minimal (a single |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'm assuming you need long term storage i.e. across reboots, and that this is for an app. If you need storage just while the app is closed, then you can implement a small controller that stores the value in memory. Maybe #2141 would be useful as a reference? You can store data in your own file on the flash. Have a look at what the alarm app does for example (alarm has a controller as well as the alarm runs in the background and therefore needs some storage in memory too, but if you don't need to run in the background no controller is needed). Try to avoid modifying the file too often, as the flash memory does not have infinite durability and the filesystem can cause quite a bit of read/write amplification |
Beta Was this translation helpful? Give feedback.
I'm assuming you need long term storage i.e. across reboots, and that this is for an app. If you need storage just while the app is closed, then you can implement a small controller that stores the value in memory. Maybe #2141 would be useful as a reference?
You can store data in your own file on the flash. Have a look at what the alarm app does for example (alarm has a controller as well as the alarm runs in the background and therefore needs some storage in memory too, but if you don't need to run in the background no controller is needed). Try to avoid modifying the file too often, as the flash memory does not have infinite durability and the filesystem can cause quite a bit of read/wr…