/* * Copyright (c) 2022-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 * @since 9 * @name preferences */ /** * Provides interfaces to obtain and modify preferences data. * * @namespace preferences * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 * @name preferences */ /** * Provides interfaces to obtain and modify preferences data. * * @namespace preferences * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 * @name preferences */ declare namespace preferences { /** * Indicates possible value types * * @typedef {number | string | boolean | Array | Array | Array} * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Indicates possible value types * * @typedef {number | string | boolean | Array | Array | Array} * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 10 */ /** * Indicates possible value types * * @typedef {number | string | boolean | Array | Array | Array | Uint8Array} * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since 11 */ /** * Indicates possible value types * * @typedef {number | string | boolean | Array | Array | Array | Uint8Array | object | * bigint} * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since arkts {'1.1':'12', '1.2':'20'} * @arkts 1.1&1.2 */ type ValueType = number | string | boolean | Array | Array | Array | Uint8Array | object | bigint; /** * Indicates the maximum length of a key (80 characters). * * @constant * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Indicates the maximum length of a key (80 characters). * * @constant * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * Indicates the maximum length of a key (80 characters). * * @constant * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since 11 */ /** * Maximum length of a key. * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since 12 */ const MAX_KEY_LENGTH: number; /** * Indicates the maximum length of a string (8192 characters). * * @constant * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Indicates the maximum length of a string (8192 characters). * * @constant * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * Indicates the maximum length of a string (8192 characters). * * @constant * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since 11 */ /** * Maximum length of a value. * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since 12 */ const MAX_VALUE_LENGTH: number; /** * the storage type * * @enum { number } * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since 18 */ enum StorageType { /** * XML storage type * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since 18 */ XML = 0, /** * GSKV storage type * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since 18 */ GSKV } /** * Manages preferences file configurations. * * @interface Options * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * Manages preferences file configurations. * * @interface Options * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ interface Options { /** * The preferences file name. * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * The preferences file name. * * @type { string } * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ name: string; /** * Application Group Id. * * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @StageModelOnly * @since 10 */ /** * Application Group Id. * * @type { ?(string | null | undefined) } * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @StageModelOnly * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ dataGroupId?: string | null | undefined; /** * The preferences storage type. * * @type { ?(StorageType | null | undefined) } * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since 18 */ storageType?: StorageType | 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ function getPreferencesSync(context: Context, options: Options): Preferences; /** * check the {@link StorageType} type is supported or not on current system. * @param { StorageType } type - Indicates storage type which want to check. * @returns { boolean } a boolean value indicates this system support the type or not. * @throws { BusinessError } 401 - Parameter error. Possible causes: Incorrect parameter types * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @atomicservice * @since 18 */ function isStorageTypeSupported(type: StorageType): boolean; /** * 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 } 15500010 - Failed to delete the user preferences persistence file. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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 } 15500010 - Failed to delete the user preferences persistence file. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 the user preferences persistence file. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15500010 - Failed to delete the user preferences persistence file. * @throws { BusinessError } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 the user preferences persistence file. * @throws { BusinessError } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15500010 - Failed to delete the user preferences persistence file. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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 } 15500010 - Failed to delete the user preferences persistence file. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 the user preferences persistence file. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15500010 - Failed to delete the user preferences persistence file. * @throws { BusinessError } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 the user preferences persistence file. * @throws { BusinessError } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 } 15501001 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 - The operations is supported in stage mode only. * @throws { BusinessError } 15501002 - Invalid dataGroupId. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 * @since 9 */ /** * 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 * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Obtains all the keys and values of a preferences in an object. * * @returns { Promise } The values and keys in an object. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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. *

When the value contains strings in a non-UTF-8 format, use the Uint8Array type for storage. * Otherwise, the format of the persistent file is incorrect and the file is damaged. *

If the corresponding key already exists, the {@link put} method will overwrite its value. * You can use the {@link #hasSync} method to check whether the corresponding key-value pair exists. * * @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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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 * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ 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; * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * 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; * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ flush(callback: AsyncCallback): void; /** * Asynchronously saves the {@link Preferences} object to the file. * * @returns { Promise } A promise object. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Asynchronously saves the {@link Preferences} object to the file. * * @returns { Promise } A promise object. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 arkts {'1.1':'11', '1.2':'20'} * @arkts 1.1&1.2 */ flush(): Promise; /** * Saves the {@link Preferences} object to the file. * * @throws { BusinessError } 15500000 - Inner error. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @atomicservice * @since 14 */ flushSync(): void; /** * Registers an observer to listen for the change of a {@link Preferences} object. * * @param { 'change' } type - Indicates the callback when preferences changes. * @param { Callback<{ key: string }> } 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Registers an observer to listen for the change of a {@link Preferences} object. * * @param { 'change' } type - Indicates the callback when preferences changes. * @param { Function } 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 11 */ 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 { Function } 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 } 15500019 - Failed to obtain the subscription service. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 10 */ /** * 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 11 */ 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 12 */ /** * 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 * @crossplatform * @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<{ key: string }> } 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 9 */ /** * Unregisters an existing observer. * * @param { 'change' } type - Indicates the callback when preferences changes. * @param { Function } 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @crossplatform * @since 10 */ /** * 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 11 */ off(type: 'change', callback?: Callback): void; /** * Unregisters an existing observer. * * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes. * @param { Function } 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. * @syscap SystemCapability.DistributedDataManager.Preferences.Core * @since 10 */ /** * 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 11 */ 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 */ /** * 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 * @crossplatform * @atomicservice * @since 20 */ off(type: 'dataChange', keys: Array, callback?: Callback>): void; } } export default preferences;