Storage interface

Methods for persisting game and save data.

Methods

clear()
Removes all key-value pairs, if there are any.

getItem(key)
Returns the current value associated with the given key, or null if the given key does not exist.

removeItem(key)
Removes the key-value pair with the given key, if a key-value pair with the given key exists.

setItem(key, value)
Sets the value of the pair identified by key to value, creating a new key-value pair if none existed for key previously.

Requirements

  • Your game must use this interface to save progress when users have made material progress such as completing a level.
  • Your game must restore any saved progress when the game starts.
  • Your game must be able to restore saved progress from previous versions of the game.
  • The total size of saved game must be less than 3 MiB and should be less than 500 KiB.