SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Store User Preferences on Device

Overview

🎓 intermediate 25 min. SAP Build AppsIntermediateSAP Business Technology PlatformSAP Build

You will learn

  • How to store information on-device
  • How to fetch information from on-device storage
  • How to use the global canvas for logic that should be run at app launch
  • How to use the translations feature
  • How to use formulas to style UI based on a variable value
Merituuli Melkko M Merituuli Melkko September 22, 2024
Created by August 1, 2023
Contributors

Prerequisites

Prerequisites

Steps

Store the user’s preferences or other data that should persist every time the user opens the app on the user’s device using SAP Build Apps’ on-device storage data resource.

Intro

This tutorial shows you how to store a user’s preferences on the user’s device so the user can have a consistent experience every time they open the app. In this tutorial, we will store information on the language the user prefers and whether the app should be in light or dark mode. The same principles can be used to store other similar data as well.

Step 1 Set up on-device storage

Let’s start by creating an on-device storage data entity for storing preferences. Due to the nature of on-device storage as a data entity, while we would only need to store two properties in this case, a whole data entity is created.

On-device storage
On-device storage

Call the entity Preferences, and click Add.

You might notice that the data entity has automatically an ID field. Do not remove this field, as you will need it to use some of the data flow functions. Instead, add two new fields:

  • darkMode, select true/false
  • language, select text

Add new field
Add new field

Save your changes and return to the UI canvas.

Step 2 Configure variables
+
Step 3 Fetch data and store in app variable
+
Step 4 Set up translations
+
Step 5 UI to modify preferences
+
Step 6 Modify UI for dark mode (Opional)
+
Step 7 Save preferences to on-device storage
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 7
1. Set up on-device storage 2. Configure variables 3. Fetch data and store in app variable 4. Set up translations 5. UI to modify preferences 6. Modify UI for dark mode (Opional) 7. Save preferences to on-device storage

Learn more →