From 2004eda643becbd6b66d65a95b1a4264be1c7a65 Mon Sep 17 00:00:00 2001 From: yanhui Date: Mon, 19 May 2025 19:31:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Preferneces=20Arkts=E9=9D=99=E6=80=81?= =?UTF-8?q?=E5=8C=96=E6=BC=94=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhui Change-Id: Ifd7741d215497203372bf79bb9dcc0bbf628edd9 --- api/@ohos.data.preferences.d.ets | 873 +++++++++++++++++++++++++++++++ 1 file changed, 873 insertions(+) create mode 100644 api/@ohos.data.preferences.d.ets diff --git a/api/@ohos.data.preferences.d.ets b/api/@ohos.data.preferences.d.ets new file mode 100644 index 0000000000..04f6ec7527 --- /dev/null +++ b/api/@ohos.data.preferences.d.ets @@ -0,0 +1,873 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit ArkData + */ + +import { AsyncCallback, Callback } from './@ohos.base'; +import Context from './application/BaseContext'; + +/** + * Provides interfaces to obtain and modify preferences data. + * + * @namespace preferences + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + * @name preferences + */ +declare namespace preferences { + /** + * Indicates possible value types + * + * @typedef {number | string | boolean | Array | Array | Array | + * Uint8Array | object | bigint} + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @atomicservice + * @since 20 + */ + type ValueType = number | string | boolean | Array | Array | Array | + Uint8Array | object | bigint; + + /** + * Maximum length of a key. + * + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + const MAX_KEY_LENGTH: number; + + /** + * Manages preferences file configurations. + * + * @interface Options + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + interface Options { + /** + * The preferences file name. + * + * @type { string } + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + name: string; + + /** + * Application Group Id. + * + * @type { ?(string | null | undefined) } + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @StageModelOnly + * @atomicservice + * @since 20 + */ + dataGroupId?: string | null | undefined; + } + + /** + * Obtains a {@link Preferences} instance matching a specified preferences file name. + *

The {@link references} instance loads all data of the preferences file and + * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @param { AsyncCallback } callback - The {@link Preferences} instance matching the specified + * preferences file name. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function getPreferences(context: Context, name: string, callback: AsyncCallback): void; + + /** + * Obtains a {@link Preferences} instance matching a specified preferences file name. + *

The {@link references} instance loads all data of the preferences file and + * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @param { AsyncCallback } callback - The {@link Preferences} instance matching the specified + * preferences file name. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function getPreferences(context: Context, options: Options, callback: AsyncCallback): void; + + /** + * Obtains a {@link Preferences} instance matching a specified preferences file name. + *

The {@link references} instance loads all data of the preferences file and + * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @returns { Promise } The {@link Preferences} instance matching the specified preferences file name. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function getPreferences(context: Context, name: string): Promise; + + /** + * Obtains a {@link Preferences} instance matching a specified preferences file name. + *

The {@link references} instance loads all data of the preferences file and + * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @returns { Promise } The {@link Preferences} instance matching the specified preferences file name. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function getPreferences(context: Context, options: Options): Promise; + + /** + * Obtains a {@link Preferences} instance matching a specified preferences file name. + * This interface is executed synchronously. + *

The {@link references} instance loads all data of the preferences file and + * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @returns { Preferences } The {@link Preferences} instance matching the specified preferences file name. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function getPreferencesSync(context: Context, options: Options): Preferences; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache which is performed by removePreferencesFromCache and deletes the + * preferences file. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15500010 - Failed to delete preferences file. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function deletePreferences(context: Context, name: string, callback: AsyncCallback): void; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache which is performed by removePreferencesFromCache and deletes the + * preferences file. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15500010 - Failed to delete preferences file. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function deletePreferences(context: Context, options: Options, callback: AsyncCallback): void; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache which is performed by removePreferencesFromCache and deletes the + * preferences file. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @returns { Promise } A promise object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15500010 - Failed to delete preferences file. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function deletePreferences(context: Context, name: string): Promise; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache which is performed by removePreferencesFromCache and deletes the + * preferences file. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @returns { Promise } A promise object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15500010 - Failed to delete preferences file. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function deletePreferences(context: Context, options: Options): Promise; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback): void; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function removePreferencesFromCache(context: Context, options: Options, callback: AsyncCallback): void; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @returns { Promise } A promise object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function removePreferencesFromCache(context: Context, name: string): Promise; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @returns { Promise } A promise object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function removePreferencesFromCache(context: Context, options: Options): Promise; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. This interface is executed synchronously. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { string } name - Indicates the preferences file name. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function removePreferencesFromCacheSync(context: Context, name: string): void; + + /** + * Deletes a {@link Preferences} instance matching a specified preferences file name + * from the cache. This interface is executed synchronously. + *

When deleting the {@link Preferences} instance, you must release all references + * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency + * will occur. + * + * @param { Context } context - Indicates the context of application or capability. + * @param { Options } options - Indicates the {@link Options} option of preferences file position. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15501001 - Only supported in stage mode. + * @throws { BusinessError } 15501002 - The data group id is not valid. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function removePreferencesFromCacheSync(context: Context, options: Options): void; + + /** + * Provides interfaces to obtain and modify preferences data. + *

The preferences data is stored in a file, which matches only one {@link Preferences} instance in the memory. + * You can use getPreferences to obtain the {@link Preferences} instance matching + * the file that stores preferences data, and use movePreferencesFromCache + * to remove the {@link Preferences} instance from the memory. + * + * @interface Preferences + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + interface Preferences { + /** + * Obtains the value of a preferences in the ValueType format. + *

If the value is {@code null} or not in the ValueType format, the default value is returned. + * + * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { ValueType } defValue - Indicates the default value to return. + * @param { AsyncCallback } callback - The value matching the specified key if it is found; + * returns the default value otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 120 + */ + get(key: string, defValue: ValueType, callback: AsyncCallback): void; + + /** + * Obtains the value of a preferences in the ValueType format. + *

If the value is {@code null} or not in the ValueType format, the default value is returned. + * + * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { ValueType } defValue - Indicates the default value to return. + * @returns { Promise } The value matching the specified key if it is found; + * returns the default value otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + get(key: string, defValue: ValueType): Promise; + + /** + * Obtains the value of a preferences in the ValueType format. This interface is executed synchronously. + *

If the value is {@code null} or not in the ValueType format, the default value is returned. + * + * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { ValueType } defValue - Indicates the default value to return. + * @returns { ValueType } The value matching the specified key if it is found; + * returns the default value otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + getSync(key: string, defValue: ValueType): ValueType; + + /** + * Obtains all the keys and values of a preferences in an object. + * + * @param { AsyncCallback } callback - The values and keys in an object. + * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + getAll(callback: AsyncCallback): void; + + /** + * Obtains all the keys and values of a preferences in an object. + * + * @returns { Promise } The values and keys in an object. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + getAll(): Promise; + + /** + * Obtains all the keys and values of a preferences in an object. This interface + * is executed synchronously. + * + * @returns { Object } The values and keys in an object. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + getAllSync(): Object; + + /** + * Checks whether the {@link Preferences} object contains a preferences matching a specified key. + * + * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { AsyncCallback } callback - {@code true} if the {@link Preferences} object contains + * a preferences with the specified key;returns {@code false} otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + has(key: string, callback: AsyncCallback): void; + + /** + * Checks whether the {@link Preferences} object contains a preferences matching a specified key. + * + * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @returns { Promise } {@code true} if the {@link Preferences} object contains + * a preferences with the specified key; returns {@code false} otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + has(key: string): Promise; + + /** + * Checks whether the {@link Preferences} object contains a preferences matching a specified key. This interface + * is executed synchronously. + * + * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @returns { boolean } {@code true} if the {@link Preferences} object contains + * a preferences with the specified key; returns {@code false} otherwise. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + hasSync(key: string): boolean; + + /** + * Sets an int value for the key in the {@link Preferences} object. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { ValueType } value - Indicates the value of the preferences. + * MAX_VALUE_LENGTH. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + put(key: string, value: ValueType, callback: AsyncCallback): void; + + /** + * Sets an int value for the key in the {@link Preferences} object. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { ValueType } value - Indicates the value of the preferences. + * MAX_VALUE_LENGTH. + * @returns { Promise } A promise object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + put(key: string, value: ValueType): Promise; + + /** + * Sets an int value for the key in the {@link Preferences} object. This interface is executed synchronously. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { ValueType } value - Indicates the value of the preferences. + * MAX_VALUE_LENGTH. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + putSync(key: string, value: ValueType): void; + + /** + * Deletes the preferences with a specified key from the {@link Preferences} object. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + delete(key: string, callback: AsyncCallback): void; + + /** + * Deletes the preferences with a specified key from the {@link Preferences} object. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the + * file. + * + * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @returns { Promise } A promise object. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + delete(key: string): Promise; + + /** + * Deletes the preferences with a specified key from the {@link Preferences} object. This interface is + * executed synchronously.

You can call the {@link #flush} method to save the {@link Preferences} + * object to the file. + * + * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. + * MAX_KEY_LENGTH. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + deleteSync(key: string): void; + + /** + * Clears all preferences from the {@link Preferences} object. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the file. + * + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + clear(callback: AsyncCallback): void; + + /** + * Clears all preferences from the {@link Preferences} object. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the file. + * + * @returns { Promise } A promise object. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + clear(): Promise; + + /** + * Clears all preferences from the {@link Preferences} object. This interface is executed synchronously. + *

You can call the {@link #flush} method to save the {@link Preferences} object to the file. + * + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + clearSync(): void; + + /** + * Asynchronously saves the {@link Preferences} object to the file. + * + * @param { AsyncCallback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + flush(callback: AsyncCallback): void; + + /** + * Asynchronously saves the {@link Preferences} object to the file. + * + * @returns { Promise } A promise object. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + flush(): Promise; + + /** + * Registers an observer to listen for the change of a {@link Preferences} object. + * + * @param { 'change' } type - Indicates the callback when preferences changes. + * @param { Callback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + on(type: 'change', callback: Callback): void; + + /** + * Registers an observer to listen for the change of a {@link Preferences} object. + * + * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes. + * @param { Callback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @throws { BusinessError } 15500019 - Failed to obtain the subscription service. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @atomicservice + * @since 20 + */ + on(type: 'multiProcessChange', callback: Callback): void; + + /** + * Registers an observer to listen for changes to the {@ link Preferences} object. + * + * @param { 'dataChange' } type - Indicates the type of the event to observe. + * @param { Array } keys - Indicates one or more keys to listen for. + * @param { Callback> } callback - Indicates the callback used to return the data change. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @atomicservice + * @since 20 + */ + on(type: 'dataChange', keys: Array, callback: Callback>): void; + + /** + * Unregisters an existing observer. + * + * @param { 'change' } type - Indicates the callback when preferences changes. + * @param { Callback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + off(type: 'change', callback?: Callback): void; + + /** + * Unregisters an existing observer. + * + * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes. + * @param { Callback } callback - Indicates the callback function. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @atomicservice + * @since 20 + */ + off(type: 'multiProcessChange', callback?: Callback): void; + + /** + * Unregisters an observer for changes to the {@ link Preferences} object. + * + * @param { 'dataChange' } type - Indicates the event type. + * @param { Array } keys - Indicates the data whose changes are not observed. + * @param { Callback> } callback - Indicates the callback to unregister. + * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 15500000 - Inner error. + * @syscap SystemCapability.DistributedDataManager.Preferences.Core + * @atomicservice + * @since 12 + */ + off(type: 'dataChange', keys: Array, callback?: Callback>): void; + } +} + +export default preferences; -- Gitee From dbfbd047a5acef37162f67e020651e0e504e3f07 Mon Sep 17 00:00:00 2001 From: yanhui Date: Wed, 21 May 2025 10:19:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=87=E6=8D=A2=E4=B8=BA=E6=89=93?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E7=9A=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhui Change-Id: Ib32ac3e052a13b8a9c033bac28a8bfecb28eea12 --- api/@ohos.data.preferences.d.ets | 873 ------------------------------- api/@ohos.data.preferences.d.ts | 39 +- 2 files changed, 26 insertions(+), 886 deletions(-) delete mode 100644 api/@ohos.data.preferences.d.ets diff --git a/api/@ohos.data.preferences.d.ets b/api/@ohos.data.preferences.d.ets deleted file mode 100644 index 04f6ec7527..0000000000 --- a/api/@ohos.data.preferences.d.ets +++ /dev/null @@ -1,873 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * @kit ArkData - */ - -import { AsyncCallback, Callback } from './@ohos.base'; -import Context from './application/BaseContext'; - -/** - * Provides interfaces to obtain and modify preferences data. - * - * @namespace preferences - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - * @name preferences - */ -declare namespace preferences { - /** - * Indicates possible value types - * - * @typedef {number | string | boolean | Array | Array | Array | - * Uint8Array | object | bigint} - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @atomicservice - * @since 20 - */ - type ValueType = number | string | boolean | Array | Array | Array | - Uint8Array | object | bigint; - - /** - * Maximum length of a key. - * - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - const MAX_KEY_LENGTH: number; - - /** - * Manages preferences file configurations. - * - * @interface Options - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - interface Options { - /** - * The preferences file name. - * - * @type { string } - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - name: string; - - /** - * Application Group Id. - * - * @type { ?(string | null | undefined) } - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @StageModelOnly - * @atomicservice - * @since 20 - */ - dataGroupId?: string | null | undefined; - } - - /** - * Obtains a {@link Preferences} instance matching a specified preferences file name. - *

The {@link references} instance loads all data of the preferences file and - * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @param { AsyncCallback } callback - The {@link Preferences} instance matching the specified - * preferences file name. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function getPreferences(context: Context, name: string, callback: AsyncCallback): void; - - /** - * Obtains a {@link Preferences} instance matching a specified preferences file name. - *

The {@link references} instance loads all data of the preferences file and - * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @param { AsyncCallback } callback - The {@link Preferences} instance matching the specified - * preferences file name. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function getPreferences(context: Context, options: Options, callback: AsyncCallback): void; - - /** - * Obtains a {@link Preferences} instance matching a specified preferences file name. - *

The {@link references} instance loads all data of the preferences file and - * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @returns { Promise } The {@link Preferences} instance matching the specified preferences file name. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function getPreferences(context: Context, name: string): Promise; - - /** - * Obtains a {@link Preferences} instance matching a specified preferences file name. - *

The {@link references} instance loads all data of the preferences file and - * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @returns { Promise } The {@link Preferences} instance matching the specified preferences file name. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function getPreferences(context: Context, options: Options): Promise; - - /** - * Obtains a {@link Preferences} instance matching a specified preferences file name. - * This interface is executed synchronously. - *

The {@link references} instance loads all data of the preferences file and - * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @returns { Preferences } The {@link Preferences} instance matching the specified preferences file name. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function getPreferencesSync(context: Context, options: Options): Preferences; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache which is performed by removePreferencesFromCache and deletes the - * preferences file. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15500010 - Failed to delete preferences file. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function deletePreferences(context: Context, name: string, callback: AsyncCallback): void; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache which is performed by removePreferencesFromCache and deletes the - * preferences file. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15500010 - Failed to delete preferences file. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function deletePreferences(context: Context, options: Options, callback: AsyncCallback): void; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache which is performed by removePreferencesFromCache and deletes the - * preferences file. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @returns { Promise } A promise object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15500010 - Failed to delete preferences file. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function deletePreferences(context: Context, name: string): Promise; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache which is performed by removePreferencesFromCache and deletes the - * preferences file. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @returns { Promise } A promise object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15500010 - Failed to delete preferences file. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function deletePreferences(context: Context, options: Options): Promise; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback): void; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function removePreferencesFromCache(context: Context, options: Options, callback: AsyncCallback): void; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @returns { Promise } A promise object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function removePreferencesFromCache(context: Context, name: string): Promise; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @returns { Promise } A promise object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function removePreferencesFromCache(context: Context, options: Options): Promise; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache. This interface is executed synchronously. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { string } name - Indicates the preferences file name. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function removePreferencesFromCacheSync(context: Context, name: string): void; - - /** - * Deletes a {@link Preferences} instance matching a specified preferences file name - * from the cache. This interface is executed synchronously. - *

When deleting the {@link Preferences} instance, you must release all references - * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency - * will occur. - * - * @param { Context } context - Indicates the context of application or capability. - * @param { Options } options - Indicates the {@link Options} option of preferences file position. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15501001 - Only supported in stage mode. - * @throws { BusinessError } 15501002 - The data group id is not valid. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - function removePreferencesFromCacheSync(context: Context, options: Options): void; - - /** - * Provides interfaces to obtain and modify preferences data. - *

The preferences data is stored in a file, which matches only one {@link Preferences} instance in the memory. - * You can use getPreferences to obtain the {@link Preferences} instance matching - * the file that stores preferences data, and use movePreferencesFromCache - * to remove the {@link Preferences} instance from the memory. - * - * @interface Preferences - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - interface Preferences { - /** - * Obtains the value of a preferences in the ValueType format. - *

If the value is {@code null} or not in the ValueType format, the default value is returned. - * - * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { ValueType } defValue - Indicates the default value to return. - * @param { AsyncCallback } callback - The value matching the specified key if it is found; - * returns the default value otherwise. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 120 - */ - get(key: string, defValue: ValueType, callback: AsyncCallback): void; - - /** - * Obtains the value of a preferences in the ValueType format. - *

If the value is {@code null} or not in the ValueType format, the default value is returned. - * - * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { ValueType } defValue - Indicates the default value to return. - * @returns { Promise } The value matching the specified key if it is found; - * returns the default value otherwise. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - get(key: string, defValue: ValueType): Promise; - - /** - * Obtains the value of a preferences in the ValueType format. This interface is executed synchronously. - *

If the value is {@code null} or not in the ValueType format, the default value is returned. - * - * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { ValueType } defValue - Indicates the default value to return. - * @returns { ValueType } The value matching the specified key if it is found; - * returns the default value otherwise. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - getSync(key: string, defValue: ValueType): ValueType; - - /** - * Obtains all the keys and values of a preferences in an object. - * - * @param { AsyncCallback } callback - The values and keys in an object. - * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - getAll(callback: AsyncCallback): void; - - /** - * Obtains all the keys and values of a preferences in an object. - * - * @returns { Promise } The values and keys in an object. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - getAll(): Promise; - - /** - * Obtains all the keys and values of a preferences in an object. This interface - * is executed synchronously. - * - * @returns { Object } The values and keys in an object. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - getAllSync(): Object; - - /** - * Checks whether the {@link Preferences} object contains a preferences matching a specified key. - * - * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { AsyncCallback } callback - {@code true} if the {@link Preferences} object contains - * a preferences with the specified key;returns {@code false} otherwise. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - has(key: string, callback: AsyncCallback): void; - - /** - * Checks whether the {@link Preferences} object contains a preferences matching a specified key. - * - * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @returns { Promise } {@code true} if the {@link Preferences} object contains - * a preferences with the specified key; returns {@code false} otherwise. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - has(key: string): Promise; - - /** - * Checks whether the {@link Preferences} object contains a preferences matching a specified key. This interface - * is executed synchronously. - * - * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @returns { boolean } {@code true} if the {@link Preferences} object contains - * a preferences with the specified key; returns {@code false} otherwise. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - hasSync(key: string): boolean; - - /** - * Sets an int value for the key in the {@link Preferences} object. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the - * file. - * - * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { ValueType } value - Indicates the value of the preferences. - * MAX_VALUE_LENGTH. - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - put(key: string, value: ValueType, callback: AsyncCallback): void; - - /** - * Sets an int value for the key in the {@link Preferences} object. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the - * file. - * - * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { ValueType } value - Indicates the value of the preferences. - * MAX_VALUE_LENGTH. - * @returns { Promise } A promise object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - put(key: string, value: ValueType): Promise; - - /** - * Sets an int value for the key in the {@link Preferences} object. This interface is executed synchronously. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the - * file. - * - * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { ValueType } value - Indicates the value of the preferences. - * MAX_VALUE_LENGTH. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - putSync(key: string, value: ValueType): void; - - /** - * Deletes the preferences with a specified key from the {@link Preferences} object. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the - * file. - * - * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - delete(key: string, callback: AsyncCallback): void; - - /** - * Deletes the preferences with a specified key from the {@link Preferences} object. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the - * file. - * - * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @returns { Promise } A promise object. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - delete(key: string): Promise; - - /** - * Deletes the preferences with a specified key from the {@link Preferences} object. This interface is - * executed synchronously.

You can call the {@link #flush} method to save the {@link Preferences} - * object to the file. - * - * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty. - * MAX_KEY_LENGTH. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - deleteSync(key: string): void; - - /** - * Clears all preferences from the {@link Preferences} object. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the file. - * - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - clear(callback: AsyncCallback): void; - - /** - * Clears all preferences from the {@link Preferences} object. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the file. - * - * @returns { Promise } A promise object. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - clear(): Promise; - - /** - * Clears all preferences from the {@link Preferences} object. This interface is executed synchronously. - *

You can call the {@link #flush} method to save the {@link Preferences} object to the file. - * - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - clearSync(): void; - - /** - * Asynchronously saves the {@link Preferences} object to the file. - * - * @param { AsyncCallback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - flush(callback: AsyncCallback): void; - - /** - * Asynchronously saves the {@link Preferences} object to the file. - * - * @returns { Promise } A promise object. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - flush(): Promise; - - /** - * Registers an observer to listen for the change of a {@link Preferences} object. - * - * @param { 'change' } type - Indicates the callback when preferences changes. - * @param { Callback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - on(type: 'change', callback: Callback): void; - - /** - * Registers an observer to listen for the change of a {@link Preferences} object. - * - * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes. - * @param { Callback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @throws { BusinessError } 15500019 - Failed to obtain the subscription service. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @atomicservice - * @since 20 - */ - on(type: 'multiProcessChange', callback: Callback): void; - - /** - * Registers an observer to listen for changes to the {@ link Preferences} object. - * - * @param { 'dataChange' } type - Indicates the type of the event to observe. - * @param { Array } keys - Indicates one or more keys to listen for. - * @param { Callback> } callback - Indicates the callback used to return the data change. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @atomicservice - * @since 20 - */ - on(type: 'dataChange', keys: Array, callback: Callback>): void; - - /** - * Unregisters an existing observer. - * - * @param { 'change' } type - Indicates the callback when preferences changes. - * @param { Callback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @crossplatform - * @atomicservice - * @since 20 - */ - off(type: 'change', callback?: Callback): void; - - /** - * Unregisters an existing observer. - * - * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes. - * @param { Callback } callback - Indicates the callback function. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @atomicservice - * @since 20 - */ - off(type: 'multiProcessChange', callback?: Callback): void; - - /** - * Unregisters an observer for changes to the {@ link Preferences} object. - * - * @param { 'dataChange' } type - Indicates the event type. - * @param { Array } keys - Indicates the data whose changes are not observed. - * @param { Callback> } callback - Indicates the callback to unregister. - * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; - * 2. Incorrect parameter types; - * 3. Parameter verification failed. - * @throws { BusinessError } 15500000 - Inner error. - * @syscap SystemCapability.DistributedDataManager.Preferences.Core - * @atomicservice - * @since 12 - */ - off(type: 'dataChange', keys: Array, callback?: Callback>): void; - } -} - -export default preferences; diff --git a/api/@ohos.data.preferences.d.ts b/api/@ohos.data.preferences.d.ts index e7ef458150..68f281e1f0 100644 --- a/api/@ohos.data.preferences.d.ts +++ b/api/@ohos.data.preferences.d.ts @@ -113,7 +113,8 @@ declare namespace preferences { * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ const MAX_KEY_LENGTH: number; @@ -147,7 +148,8 @@ declare namespace preferences { * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ const MAX_VALUE_LENGTH: number; @@ -157,7 +159,8 @@ declare namespace preferences { * @enum { number } * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 18 + * @since arkts {'1.1':'18', '1.2':'20'} + * @arkts 1.1&1.2 */ enum StorageType { /** @@ -165,7 +168,8 @@ declare namespace preferences { * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 18 + * @since arkts {'1.1':'18', '1.2':'20'} + * @arkts 1.1&1.2 */ XML = 0, @@ -174,7 +178,8 @@ declare namespace preferences { * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 18 + * @since arkts {'1.1':'18', '1.2':'20'} + * @arkts 1.1&1.2 */ GSKV } @@ -242,7 +247,8 @@ declare namespace preferences { * @type { ?(StorageType | null | undefined) } * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 18 + * @since arkts {'1.1':'18', '1.2':'20'} + * @arkts 1.1&1.2 */ storageType?: StorageType | null | undefined; } @@ -1802,7 +1808,8 @@ declare namespace preferences { * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice - * @since 14 + * @since arkts {'1.1':'14', '1.2':'20'} + * @arkts 1.1&1.2 */ flushSync(): void; @@ -1841,7 +1848,8 @@ declare namespace preferences { * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ on(type: 'change', callback: Callback): void; @@ -1869,7 +1877,8 @@ declare namespace preferences { * @throws { BusinessError } 15500019 - Failed to obtain the subscription service. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ on(type: 'multiProcessChange', callback: Callback): void; @@ -1885,7 +1894,8 @@ declare namespace preferences { * @throws { BusinessError } 15500000 - Inner error. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ on(type: 'dataChange', keys: Array, callback: Callback>): void; @@ -1924,7 +1934,8 @@ declare namespace preferences { * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ off(type: 'change', callback?: Callback): void; @@ -1950,7 +1961,8 @@ declare namespace preferences { * @throws { BusinessError } 15500000 - Inner error. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 11 + * @since arkts {'1.1':'11', '1.2':'20'} + * @arkts 1.1&1.2 */ off(type: 'multiProcessChange', callback?: Callback): void; @@ -1966,7 +1978,8 @@ declare namespace preferences { * @throws { BusinessError } 15500000 - Inner error. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice - * @since 12 + * @since arkts {'1.1':'12', '1.2':'20'} + * @arkts 1.1&1.2 */ off(type: 'dataChange', keys: Array, callback?: Callback>): void; } -- Gitee