import{_ as t,r as p,o as l,c,b as s,d as e,e as a,a as n}from"./app-BpUB8-Q8.js";const d={},r=n(`
Notice
Due to maintenance costs, the YukiHookAPI
will no longer update this document from version 1.3.0
and switch to the API document automatically generated by the Dokka plugin in version 2.0.0
.
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.
class YukiHookPrefsBridge private constructor(private var context: Context?)
Change Records
v1.0
first
v1.1.9
modified
更名为 YukiHookModulePrefs
YukiHookPrefsBridge
Function Illustrate
YukiHookAPI
对SharedPreferences
、XSharedPreferences
的扩展存储桥实现。
在不同环境智能选择存取使用的对象。
Pay Attention
模块与宿主之前共享数据存储为实验性功能,仅在 LSPosed 环境测试通过,EdXposed 理论也可以使用但不再推荐。
使用 LSPosed 环境请在 AndroidManifests.xml
中将 xposedminversion
最低设置为 93
。
对于在模块环境中使用 PreferenceFragmentCompat
,YukiHookAPI
提供了 ModulePreferenceFragment
来实现同样的功能。
Optional Configuration
若你不想将你的模块的 xposedminversion
最低设置为 93
,你可以在 AndroidManifest.xml
中添加 xposedsharedprefs
来实现支持。
The following example
<meta-data
android:name="xposedsharedprefs"
android:value="true"/>
Change Records
v1.0.90
added
v1.1.5
deprecated
请迁移到 isPreferencesAvailable
Change Records
v1.0.78
added
v1.1.5
deprecated
请迁移到 isPreferencesAvailable
val isPreferencesAvailable: Boolean
Change Records
v1.1.5
added
Function Illustrate
获取当前
YukiHookPrefsBridge
的可用状态。
在 (Xposed) 宿主环境中返回 XSharedPreferences
可用状态 (可读)。
在模块环境中返回当前是否处于 New XSharedPreferences 模式 (可读可写)。
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")
Change Records
v1.0.5
added
v1.1.11
deprecated
键值的直接缓存功能已被移除,因为其存在内存溢出 (OOM) 问题
fun native(): YukiHookPrefsBridge
Change Records
v1.1.9
added
Function Illustrate
忽略当前环境直接使用
Context.getSharedPreferences
存取数据。
fun getString(key: String, value: String): String
Change Records
v1.0
first
Function Illustrate
获取
String
键值。
fun getStringSet(key: String, value: Set<String>): Set<String>
Change Records
v1.0.77
added
Function Illustrate
获取
Set<String>
键值。
fun getBoolean(key: String, value: Boolean): Boolean
Change Records
v1.0
first
Function Illustrate
获取
Boolean
键值。
fun getInt(key: String, value: Int): Int
Change Records
v1.0
first
Function Illustrate
获取
Int
键值。
fun getLong(key: String, value: Long): Long
Change Records
v1.0
first
Function Illustrate
获取
Long
键值。
fun getFloat(key: String, value: Float): Float
Change Records
v1.0
first
Function Illustrate
获取
Float
键值。
fun contains(key: String): Boolean
Change Records
v1.1.9
added
Function Illustrate
判断当前是否包含
key
键值的数据。
智能识别对应环境读取键值数据。
fun all(): MutableMap<String, Any?>
Change Records
v1.0.77
added
Function Illustrate
获取全部存储的键值数据。
智能识别对应环境读取键值数据。
Pay Attention
每次调用都会获取实时的数据,不受缓存控制,请勿在高并发场景中使用。
Change Records
v1.0
first
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0.77
added
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0
first
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0.77
added
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0
first
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0
first
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0
first
v1.1.9
deprecated
请迁移到 edit
方法
Change Records
v1.0
first
v1.1.9
deprecated
请迁移到 edit
方法
inline fun <reified T> get(prefs: PrefsData<T>, value: T): T
Change Records
v1.0.67
added
Function Illustrate
智能获取指定类型的键值。
Change Records
v1.0.67
added
v1.1.9
deprecated
请迁移到 edit
方法
fun edit(): Editor
Change Records
v1.1.9
added
Function Illustrate
创建新的
Editor
。
在模块环境中或启用了 isUsingNativeStorage
后使用。
Notice
在 (Xposed) 宿主环境下只读,无法使用。
fun edit(initiate: Editor.() -> Unit)
Change Records
v1.1.9
added
Function Illustrate
创建新的
Editor
。
自动调用 Editor.apply
方法。
在模块环境中或启用了 isUsingNativeStorage
后使用。
Notice
在 (Xposed) 宿主环境下只读,无法使用。
Change Records
v1.0.5
added
v1.1.11
deprecated
键值的直接缓存功能已被移除,因为其存在内存溢出 (OOM) 问题
inner class Editor internal constructor()
Change Records
v1.1.9
added
Function Illustrate
YukiHookPrefsBridge
的存储代理类。
请使用 edit
方法来获取 Editor
。
在模块环境中或启用了 isUsingNativeStorage
后使用。
Notice
在 (Xposed) 宿主环境下只读,无法使用。
fun remove(key: String): Editor
Change Records
v1.1.9
added
Function Illustrate
移除全部包含
key
的存储数据。
inline fun <reified T> remove(prefs: PrefsData<T>): Editor
Change Records
v1.1.9
added
Function Illustrate
移除
PrefsData.key
的存储数据。
fun clear(): Editor
Change Records
v1.1.9
added
Function Illustrate
移除全部存储数据。
fun putString(key: String, value: String): Editor
Change Records
v1.1.9
added
Function Illustrate
存储
String
键值。
fun putStringSet(key: String, value: Set<String>): Editor
Change Records
v1.1.9
added
Function Illustrate
存储
Set<String>
键值。
fun putBoolean(key: String, value: Boolean): Editor
Change Records
v1.1.9
added
Function Illustrate
存储
Boolean
键值。
fun putInt(key: String, value: Int): Editor
Change Records
v1.1.9
added
Function Illustrate
存储
Int
键值。
fun putLong(key: String, value: Long): Editor
Change Records
v1.1.9
added
Function Illustrate
存储
Long
键值。
fun putFloat(key: String, value: Float): Editor
Change Records
v1.1.9
added
Function Illustrate
存储
Float
键值。
inline fun <reified T> put(prefs: PrefsData<T>, value: T): Editor
Change Records
v1.1.9
added
Function Illustrate
智能存储指定类型的键值。
fun commit(): Boolean
Change Records
v1.1.9
added
Function Illustrate
提交更改 (同步)。
fun apply()
Change Records
v1.1.9
added
Function Illustrate
`,249);function k(m,b){const o=p("ExternalLinkIcon");return l(),c("div",null,[r,s("p",null,[e("详见 "),s("a",i,[e("New XSharedPreferences"),a(o)]),e("。")]),g,h,s("p",null,[e("太极请参阅 "),s("a",u,[e("文件权限/配置/XSharedPreference"),a(o)]),e("。")]),y,s("p",null,[e("详见 "),s("a",A,[e("New XSharedPreferences"),a(o)]),e("。")]),D])}const C=t(d,[["render",k],["__file","YukiHookPrefsBridge.html.vue"]]);export{C as default};提交更改 (异步)。