Sign in

Google Code Help

How do I store user settings or preferences?

Print
The API offers an object named options which will handle the storing of user settings and preferences for you.

The SDK contains a few examples of how to use the options object, namely "OptionsDialog" and "DigitalClockFont".

Some things to know about the options object:

1. You can set up default values for the first time the gadget is run using the putDefaultValue method.

Let's say you do this:
  options.putDefaultValue("foo", "bar");

If there is no entry for "foo", either because it was never set or the entry was removed, options.getValue("foo") will return "bar".

2. You can be notified when the options object is modified by setting a handler for onoptionchanged within the view element.

Tell us how we're doing: Please answer a few questions about your experience to help us improve our Help Center.