Skip to content

使用初探

持久化数据共享通过ESSharedDataManager进行管理。

初始化

示例代码:

点击查看源码
js
ESSharedDataManager.init().then(
() => {}, error => {}
)

读写自身ESApp共享的数据

读共享数据

参数

属性类型必填说明
keyString共享数据的key
defValue共享数据的默认类型共享数据的默认返回值
点击查看源码
js
ESSharedDataManager.getBoolean(key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getInt(key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getLong(key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getString(key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getArray(key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getMap(key, defValue).then(
() => {}, error => {}
)

写共享数据

参数

属性类型必填说明
secretKeyString共享数据的秘钥
keyString共享数据的key
value共享数据的类型共享数据的类型
modeNumber共享数据的权限
点击查看源码
js
ESSharedDataManager.putBoolean(secretKey, key, value, mode).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putInt(secretKey, key, value, mode).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putLong(secretKey, key, value, mode).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putString(secretKey, key, value, mode).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putArray(secretKey, key, value, mode).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putMap(secretKey, key, value, mode).then(
() => {}, error => {}
)

读写其他ESApp共享的数据

读共享数据

参数

属性类型必填说明
paramsString共享数据的参数
keyString共享数据的key
defValue共享数据的类型共享数据的默认值

params参数

属性类型必填说明
packageNameString其他ESApp的包名
secretKeyString共享数据的秘钥
点击查看源码
js
ESSharedDataManager.getSharedBoolean(params, key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getSharedInt(params, key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getSharedLong(params, key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getSharedString(params, key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getSharedArray(params, key, defValue).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.getSharedMap(params, key, defValue).then(
() => {}, error => {}
)

写共享数据

参数

属性类型必填说明
paramsString共享数据的参数
keyString共享数据的key
defValue共享数据的类型共享数据的默认值

params参数

属性类型必填说明
packageNameString其他ESApp的包名
secretKeyString共享数据的秘钥
点击查看源码
js
ESSharedDataManager.putSharedBoolean(params, key, value).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putSharedInt(params, key, value).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putSharedLong(params, key, value).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putSharedString(params, key, value).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putSharedArray(params, key, value).then(
() => {}, error => {}
)
点击查看源码
js
ESSharedDataManager.putSharedMap(params, key, value).then(
() => {}, error => {}
)