Within my widget, I would like to give the user the possibility to set certain settings and I'd like these settings to be remembered the next time the user starts the widget.
For example, let's say I have a widget which displays the atmospheric pressure in mmHg by default. When the user presses the Menu key within the widget, they are presented with a menu that allows them to choose a different measurement unit for displaying atmospheric pressure such as mm (In), milibars etc The issue I have is that the next time they start the widget, this setting will be lost and the pressure will once again default to mmHg.
Currently I'm using the code below for this and the issue is that the value of the pressureUnit variable will again default to "mmHg" next time I start the widget. How can I set this in such a way in the code so that the pressure unit value the user chooses is remembered on widget restart?
var pressureUnit = "mmHg";
class MenuTest extends Ui.MenuInputDelegate {
function onMenuItem(value) {
if( value == 0 ) {
pressureUnit = "mmHg";
}
else {
pressureUnit = "milibars";
}
}
}
Thank you very much!