Skip To Content

SecureStorage QML Type

Stores data encrypted into the system keychain. More...

Import Statement: import ArcGIS.AppFramework.SecureStorage 1.0

Properties

Signals

  • error( string errorMessage)

Methods

Detailed Description

This code sample demonstrates usage of the SecureStorage component.

Item {
        TextField {
                id: key
                placeholderText: "Enter key"
        }

        TextField {
                id: value
                placeholderText: "Enter value"
                anchors.left: key.right
        }

        //Click on the button to store data in the keychain
        Button {
                id: secureButton
                text: qsTr("Secure Data")
                onClicked: {
                        SecureStorage.setValue(key.text,value.text)
                }
                anchors.top:value.bottom
                anchors.topMargin: 10 * AppFramework.displayScaleFactor
        }

        //Click on the button to retrieve data
        Button {
                id: retrieveButton
                text: qsTr("Retrieve Data")
                onClicked: {
                        retrieveData.text = qsTr("Value: ") + SecureStorage.value(key.text)
                }
                anchors.top: secureButton.bottom
                anchors.topMargin: 10 * AppFramework.displayScaleFactor
        }

        //Display retrieved data
        Text {
                id: retrieveData
                anchors.top: retrieveButton.bottom
                anchors.topMargin: 10 * AppFramework.displayScaleFactor
        }

        //Display maximum key length supported by the operating system
        Text {
                id: maximumKeyLength
                text: qsTr("Maximum Key Length: ") + SecureStorage.maximumKeyLength
                anchors.top: retrieveData.bottom
                anchors.topMargin: 10 * AppFramework.displayScaleFactor
        }

        //Display maximum value length supported by the operating system
        Text {
                id: maximumValueLength
                text: qsTr("Maximum Value Length: ") + SecureStorage.maximumValueLength
                anchors.top: maximumKeyLength.bottom
                anchors.topMargin: 10 * AppFramework.displayScaleFactor
        }
}

Property Documentation

[read-only] maximumKeyLength : int

Returns the maximum key length supported by the operating system.

If the key you need to store is larger than the key length, consider splitting and storing the key separately.


[read-only] maximumValueLength : int

Returns the maximum value length supported by the operating system.

If the value you need to store is larger than the value length, consider splitting and storing the value separately.


Signal Documentation

error( string errorMessage)

Signal emitted when an error is encountered when executing the setValue or value methods.


Method Documentation

bool setValue(var key, var value)

Stores data in the keychain associated with the provided key.

If you use the same key twice, the previous value associated with the key will be overwritten.

If you enter a valid key with an empty string, it will remove the key present in the keychain.

The key parameter

The key to be used to retrieve the value. This key cannot be null or an empty string.

Be aware that Android will encounter an exception if certain special characters, such as /, are used in keys.

The value parameter

The value to encrypt and store.

See also value().


var value(var key)

Retrieves data associated with the key.

The key parameter

The key to return the encrypted value for.

See also setValue().