Module: Toybox.Application.Storage

Overview

The Storage module provides persistent storage to applications.

Storage provides access to persistent disk storage.

Since:

API Level 2.4.0

Typedef Summary collapse

Instance Method Summary collapse

Instance Method Details

clearValues() as Void

Clear the object store for the application.

Since:

API Level 2.4.0

Throws:

deleteValue(key as Storage.KeyType) as Void

Delete the given key from the object store.

Parameters:

See Also:

Since:

API Level 2.4.0

Throws:

getValue(key as Storage.KeyType) as Storage.ValueType

Get the data associated with a given key from the object store.

Values must first be set with setValue() before they are can be obtained with getValue.

Note:

Symbols can change from build to build and are not to be used for for Keys or Values

Parameters:

  • key(Storage.KeyType)

    The key of the value to retrieve from the object store

Returns:

  • Storage.ValueType

    The content associated with the key, or null if the key is not in the object store

See Also:

Since:

API Level 2.4.0

Throws:

setValue(key as Storage.KeyType, value as Storage.ValueType) as Void

Store the given data in the object.

Support for storing object types has been expanded over time.

There is a limit on the size of the Object Store that can vary between devices. If you reach this limit, the value will not be saved and an exception will be thrown. Also, values are limited to 32 KB in size.

Note:

Symbols can change from build to build and are not to be used for for Keys or Values

Parameters:

  • key(Storage.KeyType)

    The key used to store and retrieve the value from the object store (cannot be a Symbol)

  • value(Storage.ValueType)

    The value to put into the object store

Example:

using Toybox.Application.Storage;

Storage.setValue("number", 2);               // set value for "number" key
Storage.setValue("float", 3.14);             // set value for "float" key
Storage.setValue("string", "Hello World!");  // set value for "string" key
Storage.setValue("boolean", true);           // set value for "boolean" key

var int = Storage.getValue("number");          // get value for "number" key
var float = Storage.getValue("float");         // get value for "float" key
var string = Storage.getValue("string");       // get value for "string" key
var boolean = Storage.getValue("boolean");     // get value for "boolean" key

See Also:

Since:

API Level 2.4.0

Throws:


Generated Mar 10, 2026, 11:32:34 AM