Notice
The English translation of this page has not been completed, you are welcome to contribute translations to us.
You can use the Chrome Translation Plugin to translate entire pages for reference.
YukiHookPrefsBridge - class
class YukiHookPrefsBridge private constructor(private var context: Context?)
Change Records
v1.0 first
v1.1.9 modified
更名为 YukiHookModulePrefsYukiHookPrefsBridge
Function Illustrate
YukiHookAPI对SharedPreferences、XSharedPreferences的扩展存储桥实现。
在不同环境智能选择存取使用的对象。
Pay Attention
模块与宿主之前共享数据存储为实验性功能,仅在 LSPosed 环境测试通过,EdXposed 理论也可以使用但不再推荐。
使用 LSPosed 环境请在 AndroidManifests.xml 中将 xposedminversion 最低设置为 93。
若你在按照规定配置后依然无法使用或出现文件权限错误问题,可以参考 isEnableHookSharedPreferences。
未使用 LSPosed 环境请将你的模块 API 降至 26 以下,YukiHookAPI 将会尝试使用 makeWorldReadable 但仍有可能不成功。
太极请参阅 文件权限/配置/XSharedPreference。
对于在模块环境中使用 PreferenceFragmentCompat,YukiHookAPI 提供了 ModulePreferenceFragment 来实现同样的功能。
Optional Configuration
若你不想将你的模块的 xposedminversion 最低设置为 93,你可以在 AndroidManifest.xml 中添加 xposedsharedprefs 来实现支持。
The following example
<meta-data
android:name="xposedsharedprefs"
android:value="true"/>
isXSharePrefsReadable - field
Change Records
v1.0.90 added
v1.1.5 deprecated
请迁移到 isPreferencesAvailable
isRunInNewXShareMode - field
Change Records
v1.0.78 added
v1.1.5 deprecated
请迁移到 isPreferencesAvailable
isPreferencesAvailable - field
val isPreferencesAvailable: Boolean
Change Records
v1.1.5 added
Function Illustrate
获取当前
YukiHookPrefsBridge的可用状态。
在 (Xposed) 宿主环境中返回 XSharedPreferences 可用状态 (可读)。
在模块环境中返回当前是否处于 New XSharedPreferences 模式 (可读可写)。
name - method
fun name(name: String): YukiHookPrefsBridge
Change Records
v1.0 first
Function Illustrate
自定义 Sp 存储名称。
Function Example
在 Activity 中的使用方法。
The following example
prefs("custom_name").getString("custom_key")
在 (Xposed) 宿主环境 PackageParam 中的使用方法。
The following example
prefs("custom_name").getString("custom_key")
direct - method
Change Records
v1.0.5 added
v1.1.11 deprecated
键值的直接缓存功能已被移除,因为其存在内存溢出 (OOM) 问题
native - method
fun native(): YukiHookPrefsBridge
Change Records
v1.1.9 added
Function Illustrate
忽略当前环境直接使用
Context.getSharedPreferences存取数据。
getString - method
fun getString(key: String, value: String): String
Change Records
v1.0 first
Function Illustrate
获取
String键值。
getStringSet - method
fun getStringSet(key: String, value: Set<String>): Set<String>
Change Records
v1.0.77 added
Function Illustrate
获取
Set<String>键值。
getBoolean - method
fun getBoolean(key: String, value: Boolean): Boolean
Change Records
v1.0 first
Function Illustrate
获取
Boolean键值。
getInt - method
fun getInt(key: String, value: Int): Int
Change Records
v1.0 first
Function Illustrate
获取
Int键值。
getLong - method
fun getLong(key: String, value: Long): Long
Change Records
v1.0 first
Function Illustrate
获取
Long键值。
getFloat - method
fun getFloat(key: String, value: Float): Float
Change Records
v1.0 first
Function Illustrate
获取
Float键值。
contains - method
fun contains(key: String): Boolean
Change Records
v1.1.9 added
Function Illustrate
判断当前是否包含
key键值的数据。
智能识别对应环境读取键值数据。
all - method
fun all(): MutableMap<String, Any?>
Change Records
v1.0.77 added
Function Illustrate
获取全部存储的键值数据。
智能识别对应环境读取键值数据。
Pay Attention
每次调用都会获取实时的数据,不受缓存控制,请勿在高并发场景中使用。
remove - method
Change Records
v1.0 first
v1.1.9 deprecated
请迁移到 edit 方法
clear - method
Change Records
v1.0.77 added
v1.1.9 deprecated
请迁移到 edit 方法
putString - method
Change Records
v1.0 first
v1.1.9 deprecated
请迁移到 edit 方法
putStringSet - method
Change Records
v1.0.77 added
v1.1.9 deprecated
请迁移到 edit 方法
putBoolean - method
Change Records
v1.0 first
v1.1.9 deprecated
请迁移到 edit 方法
putInt - method
Change Records
v1.0 first
v1.1.9 deprecated
请迁移到 edit 方法
putLong - method
Change Records
v1.0 first
v1.1.9 deprecated
请迁移到 edit 方法
putFloat - method
Change Records
v1.0 first
v1.1.9 deprecated
请迁移到 edit 方法
get - method
inline fun <reified T> get(prefs: PrefsData<T>, value: T): T
Change Records
v1.0.67 added
Function Illustrate
智能获取指定类型的键值。
put - method
Change Records
v1.0.67 added
v1.1.9 deprecated
请迁移到 edit 方法
edit - method
fun edit(): Editor
Change Records
v1.1.9 added
Function Illustrate
创建新的
Editor。
在模块环境中或启用了 isUsingNativeStorage 后使用。
Notice
在 (Xposed) 宿主环境下只读,无法使用。
edit - method
fun edit(initiate: Editor.() -> Unit)
Change Records
v1.1.9 added
Function Illustrate
创建新的
Editor。
自动调用 Editor.apply 方法。
在模块环境中或启用了 isUsingNativeStorage 后使用。
Notice
在 (Xposed) 宿主环境下只读,无法使用。
clearCache - method
Change Records
v1.0.5 added
v1.1.11 deprecated
键值的直接缓存功能已被移除,因为其存在内存溢出 (OOM) 问题
Editor - class
inner class Editor internal constructor()
Change Records
v1.1.9 added
Function Illustrate
YukiHookPrefsBridge的存储代理类。
请使用 edit 方法来获取 Editor。
在模块环境中或启用了 isUsingNativeStorage 后使用。
Notice
在 (Xposed) 宿主环境下只读,无法使用。
remove - method
fun remove(key: String): Editor
Change Records
v1.1.9 added
Function Illustrate
移除全部包含
key的存储数据。
remove - method
inline fun <reified T> remove(prefs: PrefsData<T>): Editor
Change Records
v1.1.9 added
Function Illustrate
移除
PrefsData.key的存储数据。
clear - method
fun clear(): Editor
Change Records
v1.1.9 added
Function Illustrate
移除全部存储数据。
putString - method
fun putString(key: String, value: String): Editor
Change Records
v1.1.9 added
Function Illustrate
存储
String键值。
putStringSet - method
fun putStringSet(key: String, value: Set<String>): Editor
Change Records
v1.1.9 added
Function Illustrate
存储
Set<String>键值。
putBoolean - method
fun putBoolean(key: String, value: Boolean): Editor
Change Records
v1.1.9 added
Function Illustrate
存储
Boolean键值。
putInt - method
fun putInt(key: String, value: Int): Editor
Change Records
v1.1.9 added
Function Illustrate
存储
Int键值。
putLong - method
fun putLong(key: String, value: Long): Editor
Change Records
v1.1.9 added
Function Illustrate
存储
Long键值。
putFloat - method
fun putFloat(key: String, value: Float): Editor
Change Records
v1.1.9 added
Function Illustrate
存储
Float键值。
put - method
inline fun <reified T> put(prefs: PrefsData<T>, value: T): Editor
Change Records
v1.1.9 added
Function Illustrate
智能存储指定类型的键值。
commit - method
fun commit(): Boolean
Change Records
v1.1.9 added
Function Illustrate
提交更改 (同步)。
apply - method
fun apply()
Change Records
v1.1.9 added
Function Illustrate
提交更改 (异步)。
