Using the Storage API is easy. Just get a reference to the local
storage singleton, then save strings under a string key.
// Saving preferred font size
Storage storage = Window.current().getLocalStorage();
storage.setItem("fontSize", Integer.toString(preferredFontSize));
When you need to read the value back, use
getItem()
:
String fontSize = storage.getItem("fontSize");
Complex Data? Use the Serialization API
Flavour provides a
serialization API.
You can turn a Java object into
a string, and back again. This lets you store complex objects in
Storage.
Last modified on 6 Feb 2022 by AO
Copyright © 2024 Andrew Oliver