The key-value storage system can be broken down into several main concepts:
- setting a value;
- getting a value;
- listen for changes;
This represents all the functionality you will need to implement to be able to successfully store values in the cloud.
Firstly to set a value, you call
setString, which takes a
key and a
value as parameters.
or to set an integer value:
You can then retrieve the value using
getString providing the same
a parameter which will then return the value set previously.
To remove a value that you have previously set you can use the
The extension will dispatch events when the values are changed (on another device) and when other system events occur:
- Changed: Indicates a value has changed and the event will contain an array of keys that changed
- Over Quota: Your app's key-value store has exceeded its space quota on the server
- Account Changed: The user's account was changed
- Initial Sync: The initial data synchronisation from the server was received
More information see the
KeyValueStoreEvent class documentation.
The following example shows the core concepts, setting then retrieving a value and listening
OnChanged on Unity) event.