public interface Preferences
A Preference instance is a hash map holding different values. It is stored alongside your application (SharedPreferences on Android, LocalStorage on GWT, on the desktop a Java Preferences file in a ".prefs" directory will be created, and on iOS an NSMutableDictionary will be written to the given file). CAUTION: On the desktop platform, all libgdx applications share the same ".prefs" directory. To avoid collisions use specific names like "com.myname.game1.settings" instead of "settings"
Changes to a preferences instance will be cached in memory until flush()
is invoked.
Use Application.getPreferences(String)
to look up a specific preferences instance. Note that on several backends the
preferences name will be used as the filename, so make sure the name is valid for a filename.
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
contains(String key) |
void |
flush()
Makes sure the preferences are persisted.
|
Map<String,?> |
get()
Returns a read only Map
|
boolean |
getBoolean(String key) |
boolean |
getBoolean(String key,
boolean defValue) |
float |
getFloat(String key) |
float |
getFloat(String key,
float defValue) |
int |
getInteger(String key) |
int |
getInteger(String key,
int defValue) |
long |
getLong(String key) |
long |
getLong(String key,
long defValue) |
String |
getString(String key) |
String |
getString(String key,
String defValue) |
Preferences |
put(Map<String,?> vals) |
Preferences |
putBoolean(String key,
boolean val) |
Preferences |
putFloat(String key,
float val) |
Preferences |
putInteger(String key,
int val) |
Preferences |
putLong(String key,
long val) |
Preferences |
putString(String key,
String val) |
void |
remove(String key) |
Preferences putBoolean(String key, boolean val)
Preferences putInteger(String key, int val)
Preferences putLong(String key, long val)
Preferences putFloat(String key, float val)
Preferences putString(String key, String val)
Preferences put(Map<String,?> vals)
boolean getBoolean(String key)
int getInteger(String key)
long getLong(String key)
float getFloat(String key)
boolean getBoolean(String key, boolean defValue)
int getInteger(String key, int defValue)
long getLong(String key, long defValue)
float getFloat(String key, float defValue)
boolean contains(String key)
void clear()
void remove(String key)
void flush()
Copyright © 2014. All rights reserved.