A value of a Preferences
node can be of the type String
, boolean
, byte[]
, double
, float
, int
or long
. All invocations must provide a default value, in case the specified value is not present in the Preferences
node.
Preferences preferences = Preferences.userNodeForPackage(getClass());
String someString = preferences.get("someKey", "this is the default value");
boolean someBoolean = preferences.getBoolean("someKey", true);
byte[] someByteArray = preferences.getByteArray("someKey", new byte[0]);
double someDouble = preferences.getDouble("someKey", 887284.4d);
float someFloat = preferences.getFloat("someKey", 38723.3f);
int someInt = preferences.getInt("someKey", 13232);
long someLong = preferences.getLong("someKey", 2827637868234L);