Spyros
Spyros

Reputation: 339

Is there a way to set the default values of Preferences, like e.g. in Android?

I want to initialize the Preferences default values for my mobile application. Is there a standard way to do it or should I do it in my own way?

I used the init() method to do so, but I would like to know if there is any built-in way to do it.

Upvotes: 2

Views: 596

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

I don't get the problem?

Codename One has two ways of defining the defaults for get:

String value = Preferences.get("MyKey", "DefaultValue");

or:

String otherValue = Preferences.getAndSet("MyKey", "DefaultValue");

The latter is used the default value is set into the field so you don't need to keep using default values in the code.

Upvotes: 1

Related Questions