Module: Toybox::Application::Storage

Overview

The Storage module provides persistent storage to applications.

Storage provides access to persistent disk storage.

Since:

  • 2.4.0

Instance Method Summary collapse

Instance Method Details

clearValuesObject

Note:

Background processes cannot clear the Object Store

Clear the object store for the application.

Raises:

Since:

  • 2.4.0


2278
2279
# File 'Monkeybrains.rb', line 2278

def clearValues()
end

deleteValue(key) ⇒ Object

Note:

Background processes cannot delete Object Store values

Delete the given key from the object store.

Parameters:

Raises:

Since:

  • 2.4.0


2269
2270
# File 'Monkeybrains.rb', line 2269

def deleteValue(key)
end

getValue(key) ⇒ Toybox::Lang::Object

Note:

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

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

Keys can be of the following types:

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

Parameters:

  • key (Toybox::Lang::Object)

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

Returns:

  • (Toybox::Lang::Object)

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

Raises:

See Also:

Since:

  • 2.4.0


2197
2198
# File 'Monkeybrains.rb', line 2197

def getValue(key)
end

setValue(key, value) ⇒ Object

Note:

Background processes cannot save values to the Object Store

Note:

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

Store the given data in the object.

Keys can be of the following types:

Values can be of the following types:

Values can also be of type Array or Dictionary containing the above listed types, excluding BitmapResource. There is a limit on the size of the Object Store of approximately 100KB. If you reach this limit, the value will not be saved and an exception will be thrown

Examples:

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

Parameters:

Raises:

See Also:

Since:

  • 2.4.0


2257
2258
# File 'Monkeybrains.rb', line 2257

def setValue(key, value)
end