I think more than likely I have a bug in my code, but I still want to check if maybe this is intended behavior? I tried to setValue and getValue to persist some data when I leave the WatchFace screen (such as when navigating to glances or other apps), but it only seems to be returning null and reverting to my fallback value.
function loadValue(key as String, fallbackValue as Lang.Object or Null) { var value = Storage.getValue(key); if (value == null) { return fallbackValue; } return value; } ... function onHide() as Void { ... Storage.setValue("batteryInDays", batteryInDays); } function onShow() as Void { ... batteryInDays = loadValue("batteryInDays", stats.batteryInDays); }
The reason why I don't just want to use batteryInDays from the system stats is that it's only accurate with 1 digit of precision. For example, my custom implementation will calculate the battery drain and return 7.5 days but the batteryInDays field will return 7.0