-
- All Implemented Interfaces:
-
android.content.SharedPreferences
@Deprecated() public final class XSharedPreferences implements SharedPreferences
This class is basically the same as SharedPreferencesImpl from AOSP, but read-only and without listeners support. Instead, it is made to be compatible with all ROMs.
-
-
Constructor Summary
Constructors Constructor Description XSharedPreferences(File prefFile)Read settings from the specified file. XSharedPreferences(String packageName)Read settings from the default preferences for a package. XSharedPreferences(String packageName, String prefFileName)Read settings from a custom preferences file for a package.
-
Method Summary
Modifier and Type Method Description booleanmakeWorldReadable()Tries to make the preferences file world-readable. FilegetFile()Returns the file that is backing these preferences. synchronized voidreload()Reload the settings from file if they have changed. synchronized booleanhasFileChanged()Check whether the file has changed since the last time it has been loaded. Map<String, out Object>getAll()StringgetString(String key, String defValue)Set<String>getStringSet(String key, Set<String> defValues)intgetInt(String key, int defValue)longgetLong(String key, long defValue)floatgetFloat(String key, float defValue)booleangetBoolean(String key, boolean defValue)booleancontains(String key)SharedPreferences.Editoredit()voidregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener listener)voidunregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener listener)-
Methods inherited from class android.content.SharedPreferences
contains, edit, getAll, getBoolean, getFloat, getInt, getLong, getString, getStringSet, registerOnSharedPreferenceChangeListener, unregisterOnSharedPreferenceChangeListener -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
XSharedPreferences
XSharedPreferences(File prefFile)
Read settings from the specified file.- Parameters:
prefFile- The file to read the preferences from.
-
XSharedPreferences
XSharedPreferences(String packageName)
Read settings from the default preferences for a package.- Parameters:
packageName- The package name.
-
-
Method Detail
-
makeWorldReadable
boolean makeWorldReadable()
Tries to make the preferences file world-readable.
Warning: This is only meant to work around permission "fix" functions that are partof some recoveries. It doesn't replace the need to open preferences with
{@code MODE_WORLD_READABLE}in the module's UI code. Otherwise, Android will set stricter permissions again during the next save.This will only work if executed as root (e.g.
{@code initZygote()}) and only if SELinux is disabled.
-
getFile
File getFile()
Returns the file that is backing these preferences.
Warning: The file might not be accessible directly.
-
reload
synchronized void reload()
Reload the settings from file if they have changed.
Warning: With enforcing SELinux, this call might be quite expensive.
-
hasFileChanged
synchronized boolean hasFileChanged()
Check whether the file has changed since the last time it has been loaded.
Warning: With enforcing SELinux, this call might be quite expensive.
-
getBoolean
boolean getBoolean(String key, boolean defValue)
-
edit
@Deprecated() SharedPreferences.Editor edit()
-
registerOnSharedPreferenceChangeListener
@Deprecated() void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener listener)
-
unregisterOnSharedPreferenceChangeListener
@Deprecated() void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener listener)
-
-
-
-