diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md index 6e3a16e1ad8b54ba891ea2b0d3361e9826240df6..430fed2b85aa5c25fd862ab75617ba932c53fce2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md @@ -262,6 +262,56 @@ promise.then((value) => { }) ``` +### getAll + +getAll(callback: AsyncCallback<Object>): void; + +返回含有所有键值的Object对象。 + +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core + +**参数:** + | 参数名 | 类型 | 必填 | 说明 | + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<Object> | 是 | 回调函数。返回含有所有键值的Object对象。 | + +**示例:** +```ts +preferences.get.getAll(function (err, value) { + if (err) { + console.info("getAll failed, err: " + err) + return + } + let keys = Object.keys(value) + console.info('getAll keys = ' + keys) + console.info("getAll object = " + JSON.stringify(value)) +}); +``` + +### getAll + +getAll(): Promise<Object> + +返回含有所有键值的Object对象。 + +**系统能力:** SystemCapability.DistributedDataManager.Preferences.Core + +**返回值:** + | 类型 | 说明 | + | -------- | -------- | + | Promise<Object> | Promise对象。返回含有所有键值的Object对象。 | + +**示例:** +```ts +let promise = preferences.getAll() +promise.then((value) => { + let keys = Object.keys(value) + console.info('getAll keys = ' + keys) + console.info("getAll object = " + JSON.stringify(value)) +}).catch((err) => { + console.info("getAll failed, err: " + err) +}) +``` ### put @@ -289,7 +339,6 @@ preferences.put('startup', 'auto', function (err) { }) ``` - ### put put(key: string, value: ValueType): Promise<void>