Skip to content

Storing Settings

The SAP Cloud Platform Mobile Services provides storage service for managing application-related settings.

Storage service provides management of data at three target levels:

  • Application
  • User
  • Device

Application level is the highest and Device level is the lowest.

For example, Loglevel in the application level is inherited by every user of the application. If the user changes the log level for the User Target, the change is applied only to that specific user. All the devices that authenticate with that specific user will have the user log level. If a log level is changed in Device Target level, it applies to only that specific device. The application and user log level will not change.

By default, if a target is not specified, Device-level data are provided. Additionally, mobile application developers can create their own data to be stored and retrieved using the Storage APIs. The Settings classes of foundation modules provide methods to store, read, and delete the Storage service data.

See Storage Service API in the SAP Cloud Platform Mobile Services documentation for more information.

Storage Data

Storage service supports the storing of JSON data. At the root level, mobile services-related settings are available under JSON node mobileservices/settingsExchange. The application may also store settings using custom nodes. Please refer to Storage Service API in the Mobile Services documentation for complete information. In a typical scenario, the mobile application developer only needs to be familiar with the common mobile services settings like log level.

Below is an example of a full settings document that has mobile service settings and custom settings.

    {
        "mobileservices": {
            "settingsExchange": {
                "passwordPolicy": {
                    "passwordPolicyMinLength": "8",
                    "passwordPolicyLowerRequired": "false",
                    "passwordPolicyDefaultPasswordAllowed": "false",
                    "passwordPolicyRetryLimit": "10",
                    "passwordPolicyUpperRequired": "false",
                    "passwordPolicyEnabled": "false",
                    "passwordPolicySpecialRequired": "false",
                    "passwordPolicyExpiresInNDays": "0",
                    "passwordPolicyLockTimeout": "300",
                    "passwordPolicyDigitRequired": "false",
                    "passwordPolicyMinUniqueChars": "0"
                },
                "featureVectorPolicies": {
                    "featureVectorPolicyAllEnabled": "true",
                    "restrictedPolicies": null
                },
                "logSettings": {
                    "logEntryExpiry": "7",
                    "logLevel": "NONE"
                },
                "blockWipingPolicy": {
                    "wipeDisconnectedPeriod": "0",
                    "blockWipeEnabled": "false",
                    "blockDisconnectedPeriod": "0"
                }
            }
        },
        "customAppDefinedConfigs1": {
            "appConfig1": "value1",
            "appConfig2": "value2"
        }
    }

Settings Target

Settings target refers to the level of storage data.

  • SettingTarget.APPLICATION – Any data at this level applies to all the users and mobile devices used by the mobile service application.

  • SettingTarget.USER – Any data at this level applies to all the devices for this user. By default when no node is overridden at this level, data from application level is inherited.

  • SettingTarget.DEVICE – Any data at this level applies to the device the mobile app is currently running on. By default, if no node is overridden at this level, data from user level is inherited.

In a typical usage scenario, you will be using SettingTarget.DEVICE.

Settings Path

Settings path refers to the JSON node path within the settings document.

For example, using mobileservices returns:

    {
      "settingsExchange": {
        "passwordPolicy": {
          "passwordPolicyMinLength": "8",
          "passwordPolicyLowerRequired": "false",
          "passwordPolicyDefaultPasswordAllowed": "false",
          "passwordPolicyRetryLimit": "10",
          "passwordPolicyUpperRequired": "false",
          "passwordPolicyEnabled": "false",
          "passwordPolicySpecialRequired": "false",
          "passwordPolicyExpiresInNDays": "0",
          "passwordPolicyLockTimeout": "300",
          "passwordPolicyDigitRequired": "false",
          "passwordPolicyMinUniqueChars": "0"
        },
        "featureVectorPolicies": {
          "featureVectorPolicyAllEnabled": "true",
          "restrictedPolicies": null
        },
        "logSettings": {
          "logEntryExpiry": "7",
          "logLevel": "NONE"
        },
        "blockWipingPolicy": {
            "wipeDisconnectedPeriod": "0",
            "blockWipeEnabled": "false",
            "blockDisconnectedPeriod": "0"
        }
      }
    }

mobileservices/settingsExchange/logSettings returns:

{
    "logEntryExpiry": "7",
    "logLevel": "NONE"
}

Last update: November 24, 2020