My app is not saving changed data

How to save data in the local application?
I’ve put some options for the user to select, but when I close the app and open it again, it goes back to what I initially put.
Is this happening because I haven’t put in some logic to save the data, or is it because I’m testing the app and when I launch it, it’ll be okay?

Thank you all, Vivi Folconi.

If it’s not working in preview app, this won’t work in your actual app build, either.

Here’s how I do this.

  1. Create an On-device data resource called “settings”, with properties that match all of my savable user settings
  2. On Global canvas page, add logic to load and save these settings

The way this works:

  • On app launch, it tries to get saved user settings from local storage (Get Record)
  • If that fails (must be first time app run) then write settings with default values (Create Record)
  • Try to read the settings again. This trick makes it easier to handle the read values the same way, whether the setting file was read in or was just created. There are probably other ways to solve this
  • Set app variables for each of the settings in the record, using the output of the 2nd “Get Record” block. I chose to break them out into individual settings variables because some of the components, when bound to a property inside a larger object, would destroy the rest of the properties when edited. Avoided that by doing it this way
  • You would need to add components in your app somewhere (settings page, etc.) and bind them to each of these settings (toggle, dropdown, etc).
  • The “App variable xxx changed” event for each of your settings will fire when the user changes that setting. This causes the Update Record block to run, which writes the settings record with the current value of all the settings variables

Just be sure you use the same ID for each of these blocks (Get / Create / Update record). e.g. “mySettings”

Breaking the variables into individual variables like this makes for a little more maintenance when you add or remove settings to your app. But I couldn’t make components bound to an object’s single property work right. I think there’s a bug there.