Namespace: AppPreferences

sap. AppPreferences

This plugin helps to handle native application preferences.

Methods

(static) configurePreferencesScreen(preferencesUIData, successCallbackopt, errorCallbackopt)

Add JSON array for configuring an app preferences screen (only for Android)
Parameters:
Name Type Attributes Description
preferencesUIData JSONArray JSON array for configuring an app preferences screen.
successCallback function <optional>
Callback function called when JSON array for an app preferences screen has been successfully configured.
errorCallback function <optional>
Callback function called when an error occurs while adding and checking JSON array for an app preferences screen.
Example
sap.AppPreferences.configurePreferencesScreen(preferencesUIData, 
        function(successMsg) {alert("Succeess: " + successMsg);}, 
        function(errMsg) {alert("Error: " + errMsg);} );

(static) getPreferenceValue(key, successCallbackopt, errorCallbackopt)

Get a preference value. If a preference with the given key cannot be found, the succes callback will still be invoked, but the value will be null.
Parameters:
Name Type Attributes Description
key String a unique identifier for a preference value.
successCallback function <optional>
Callback function called when a preference value has been successfully retrieved with a key.
errorCallback function <optional>
Callback function called when an error occurs while retrieving a preference value with a key.
Example
var successCallback = function(value) {
    if (value != null) {
        alert("Succeess: " + value); 
    } else {
        alert("preference does not exist.");
    }
}
sap.AppPreferences.getPreferenceValue(function() {
  "name_preference", 
   successCallback, 
   function(errMsg) {alert("Error: " + errMsg);} );

(static) getPreferenceValues(keys, successCallbackopt, errorCallbackopt)

Get multiple preference values
Parameters:
Name Type Attributes Description
keys StringArray identifier array for the preference values.
successCallback function <optional>
Callback function called when preference values have been successfully retrieved with keys.
errorCallback function <optional>
Callback function called when an error occurs while retrieving preference values with keys.
Example
sap.AppPreferences.getPreferenceValues(function() {
  ["name1","name2"],
   function(val) {alert("Succeess: " + val);},
   function(errMsg) {alert("Error: " + errMsg);} );

(static) setPreferenceValue(key, value, successCallbackopt, errorCallbackopt)

Set a key-value pair for a preference
Parameters:
Name Type Attributes Description
key String a unique identifier for a preference value.
value String a preference value set with a key.
successCallback function <optional>
Callback function called when a key-value pair for a preference has been successfully set.
errorCallback function <optional>
Callback function called when an error occurs while setting a key-value pair for a preference.
Example
sap.AppPreferences.setPreferenceValue(function() {
  "name_preference", 
  "TEST", 
   function(successMsg) {alert("Succeess: " + successMsg);}, 
   function(errMsg) {alert("Error: " + errMsg);} );

(static) setPreferenceValues(properties, successCallbackopt, errorCallbackopt)

Set key-value pairs for preference
Parameters:
Name Type Attributes Description
properties object of the javascript object as name-value pairs.
successCallback function <optional>
Callback function called when a key-value pair for a preference has been successfully set.
errorCallback function <optional>
Callback function called when an error occurs while setting a key-value pair for a preference.
Example
sap.AppPreferences.setPreferenceValue(function() {
   {"name1":"value1","name2":"value2"},
   function(successMsg) {alert("Succeess: " + successMsg);},
   function(errMsg) {alert("Error: " + errMsg);} );

(static) showPreferencesScreen(successCallbackopt, errorCallbackopt, preferencesJSON)

Show an app preferences screen (only for Android)
Parameters:
Name Type Attributes Description
successCallback function <optional>
Callback function called when an app preferences screen built by app preferences screen JSON array has been successfully shown.
errorCallback function <optional>
Callback function called when an error occurs while showing an app preferences screen.
preferencesJSON Object JSON object for app preferences screen configuration. If the parameter is provided, then there is no need to call configurePreferencesScreen separately
Example
sap.AppPreferences.showPreferencesScreen( 
        function(successMsg) {alert("Succeess: " + successMsg);}, 
        function(errMsg) {alert("Error: " + errMsg);} );