• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkData
19 */
20
21import { AsyncCallback, Callback } from './@ohos.base';
22import Context from './application/BaseContext';
23
24/**
25 * Provides interfaces to obtain and modify preferences data.
26 *
27 * @namespace preferences
28 * @syscap SystemCapability.DistributedDataManager.Preferences.Core
29 * @since 9
30 * @name preferences
31 */
32/**
33 * Provides interfaces to obtain and modify preferences data.
34 *
35 * @namespace preferences
36 * @syscap SystemCapability.DistributedDataManager.Preferences.Core
37 * @crossplatform
38 * @since 10
39 * @name preferences
40 */
41/**
42 * Provides interfaces to obtain and modify preferences data.
43 *
44 * @namespace preferences
45 * @syscap SystemCapability.DistributedDataManager.Preferences.Core
46 * @crossplatform
47 * @atomicservice
48 * @since 11
49 * @name preferences
50 */
51declare namespace preferences {
52  /**
53   * Indicates possible value types
54   *
55   * @typedef {number | string | boolean | Array<number> | Array<string> | Array<boolean>}
56   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
57   * @since 9
58   */
59  /**
60   * Indicates possible value types
61   *
62   * @typedef {number | string | boolean | Array<number> | Array<string> | Array<boolean>}
63   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
64   * @since 10
65   */
66  /**
67   * Indicates possible value types
68   *
69   * @typedef {number | string | boolean | Array<number> | Array<string> | Array<boolean> | Uint8Array}
70   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
71   * @atomicservice
72   * @since 11
73   */
74  /**
75   * Indicates possible value types
76   *
77   * @typedef {number | string | boolean | Array<number> | Array<string> | Array<boolean> | Uint8Array | object | bigint}
78   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
79   * @atomicservice
80   * @since 12
81   */
82  type ValueType = number | string | boolean | Array<number> | Array<string> | Array<boolean> | Uint8Array | object | bigint;
83
84  /**
85   * Indicates the maximum length of a key (80 characters).
86   *
87   * @constant
88   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
89   * @since 9
90   */
91  /**
92   * Indicates the maximum length of a key (80 characters).
93   *
94   * @constant
95   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
96   * @crossplatform
97   * @since 10
98   */
99  /**
100   * Indicates the maximum length of a key (80 characters).
101   *
102   * @constant
103   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
104   * @crossplatform
105   * @atomicservice
106   * @since 11
107   */
108  /**
109   * Maximum length of a key.
110   *
111   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
112   * @crossplatform
113   * @atomicservice
114   * @since 12
115   */
116  const MAX_KEY_LENGTH: number;
117
118  /**
119   * Indicates the maximum length of a string (8192 characters).
120   *
121   * @constant
122   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
123   * @since 9
124   */
125  /**
126   * Indicates the maximum length of a string (8192 characters).
127   *
128   * @constant
129   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
130   * @crossplatform
131   * @since 10
132   */
133  /**
134   * Indicates the maximum length of a string (8192 characters).
135   *
136   * @constant
137   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
138   * @crossplatform
139   * @atomicservice
140   * @since 11
141   */
142  /**
143   * Maximum length of a value.
144   *
145   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
146   * @crossplatform
147   * @atomicservice
148   * @since 12
149   */
150  const MAX_VALUE_LENGTH: number;
151
152  /**
153   * the storage type
154   *
155   * @enum { number }
156   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
157   * @atomicservice
158   * @since 18
159   */
160  enum StorageType {
161    /**
162     * XML storage type
163     *
164     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
165     * @atomicservice
166     * @since 18
167     */
168    XML = 0,
169
170    /**
171     * GSKV storage type
172     *
173     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
174     * @atomicservice
175     * @since 18
176     */
177    GSKV
178  }
179
180  /**
181   * Manages preferences file configurations.
182   *
183   * @interface Options
184   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
185   * @crossplatform
186   * @since 10
187   */
188  /**
189   * Manages preferences file configurations.
190   *
191   * @interface Options
192   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
193   * @crossplatform
194   * @atomicservice
195   * @since 11
196   */
197  interface Options {
198    /**
199     * The preferences file name.
200     *
201     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
202     * @crossplatform
203     * @since 10
204     */
205    /**
206     * The preferences file name.
207     *
208     * @type { string }
209     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
210     * @crossplatform
211     * @atomicservice
212     * @since 11
213     */
214    name: string;
215
216    /**
217     * Application Group Id.
218     *
219     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
220     * @StageModelOnly
221     * @since 10
222     */
223    /**
224     * Application Group Id.
225     *
226     * @type { ?(string | null | undefined) }
227     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
228     * @StageModelOnly
229     * @atomicservice
230     * @since 11
231     */
232    dataGroupId?: string | null | undefined;
233
234    /**
235     * The preferences storage type.
236     *
237     * @type { ?(StorageType | null | undefined) }
238     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
239     * @atomicservice
240     * @since 18
241     */
242    storageType?: StorageType | null | undefined;
243  }
244
245  /**
246   * Obtains a {@link Preferences} instance matching a specified preferences file name.
247   * <p>The {@link references} instance loads all data of the preferences file and
248   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
249   *
250   * @param { Context } context - Indicates the context of application or capability.
251   * @param { string } name - Indicates the preferences file name.
252   * @param { AsyncCallback<Preferences> } callback - The {@link Preferences} instance matching the specified
253   *        preferences file name.
254   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
255   *                                                                   2. Incorrect parameter types;
256   *                                                                   3. Parameter verification failed.
257   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
258   * @since 9
259   */
260  /**
261   * Obtains a {@link Preferences} instance matching a specified preferences file name.
262   * <p>The {@link references} instance loads all data of the preferences file and
263   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
264   *
265   * @param { Context } context - Indicates the context of application or capability.
266   * @param { string } name - Indicates the preferences file name.
267   * @param { AsyncCallback<Preferences> } callback - The {@link Preferences} instance matching the specified
268   *        preferences file name.
269   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
270   *                                                                   2. Incorrect parameter types;
271   *                                                                   3. Parameter verification failed.
272   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
273   * @crossplatform
274   * @since 10
275   */
276  /**
277   * Obtains a {@link Preferences} instance matching a specified preferences file name.
278   * <p>The {@link references} instance loads all data of the preferences file and
279   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
280   *
281   * @param { Context } context - Indicates the context of application or capability.
282   * @param { string } name - Indicates the preferences file name.
283   * @param { AsyncCallback<Preferences> } callback - The {@link Preferences} instance matching the specified
284   *        preferences file name.
285   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
286   *                                                                   2. Incorrect parameter types;
287   *                                                                   3. Parameter verification failed.
288   * @throws { BusinessError } 15500000 - Inner error.
289   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
290   * @crossplatform
291   * @atomicservice
292   * @since 11
293   */
294  function getPreferences(context: Context, name: string, callback: AsyncCallback<Preferences>): void;
295
296  /**
297   * Obtains a {@link Preferences} instance matching a specified preferences file name.
298   * <p>The {@link references} instance loads all data of the preferences file and
299   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
300   *
301   * @param { Context } context - Indicates the context of application or capability.
302   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
303   * @param { AsyncCallback<Preferences> } callback - The {@link Preferences} instance matching the specified
304   *        preferences file name.
305   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
306   *                                                                   2. Incorrect parameter types;
307   *                                                                   3. Parameter verification failed.
308   * @throws { BusinessError } 801 - Capability not supported.
309   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
310   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
311   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
312   * @crossplatform
313   * @since 10
314   */
315  /**
316   * Obtains a {@link Preferences} instance matching a specified preferences file name.
317   * <p>The {@link references} instance loads all data of the preferences file and
318   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
319   *
320   * @param { Context } context - Indicates the context of application or capability.
321   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
322   * @param { AsyncCallback<Preferences> } callback - The {@link Preferences} instance matching the specified
323   *        preferences file name.
324   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
325   *                                                                   2. Incorrect parameter types;
326   *                                                                   3. Parameter verification failed.
327   * @throws { BusinessError } 801 - Capability not supported.
328   * @throws { BusinessError } 15500000 - Inner error.
329   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
330   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
331   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
332   * @crossplatform
333   * @atomicservice
334   * @since 11
335   */
336  function getPreferences(context: Context, options: Options, callback: AsyncCallback<Preferences>): void;
337
338  /**
339   * Obtains a {@link Preferences} instance matching a specified preferences file name.
340   * <p>The {@link references} instance loads all data of the preferences file and
341   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
342   *
343   * @param { Context } context - Indicates the context of application or capability.
344   * @param { string } name - Indicates the preferences file name.
345   * @returns { Promise<Preferences> } The {@link Preferences} instance matching the specified preferences file name.
346   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
347   *                                                                   2. Incorrect parameter types;
348   *                                                                   3. Parameter verification failed.
349   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
350   * @since 9
351   */
352  /**
353   * Obtains a {@link Preferences} instance matching a specified preferences file name.
354   * <p>The {@link references} instance loads all data of the preferences file and
355   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
356   *
357   * @param { Context } context - Indicates the context of application or capability.
358   * @param { string } name - Indicates the preferences file name.
359   * @returns { Promise<Preferences> } The {@link Preferences} instance matching the specified preferences file name.
360   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
361   *                                                                   2. Incorrect parameter types;
362   *                                                                   3. Parameter verification failed.
363   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
364   * @crossplatform
365   * @since 10
366   */
367  /**
368   * Obtains a {@link Preferences} instance matching a specified preferences file name.
369   * <p>The {@link references} instance loads all data of the preferences file and
370   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
371   *
372   * @param { Context } context - Indicates the context of application or capability.
373   * @param { string } name - Indicates the preferences file name.
374   * @returns { Promise<Preferences> } The {@link Preferences} instance matching the specified preferences file name.
375   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
376   *                                                                   2. Incorrect parameter types;
377   *                                                                   3. Parameter verification failed.
378   * @throws { BusinessError } 15500000 - Inner error.
379   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
380   * @crossplatform
381   * @atomicservice
382   * @since 11
383   */
384  function getPreferences(context: Context, name: string): Promise<Preferences>;
385
386  /**
387   * Obtains a {@link Preferences} instance matching a specified preferences file name.
388   * <p>The {@link references} instance loads all data of the preferences file and
389   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
390   *
391   * @param { Context } context - Indicates the context of application or capability.
392   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
393   * @returns { Promise<Preferences> } The {@link Preferences} instance matching the specified preferences file name.
394   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
395   *                                                                   2. Incorrect parameter types;
396   *                                                                   3. Parameter verification failed.
397   * @throws { BusinessError } 801 - Capability not supported.
398   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
399   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
400   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
401   * @crossplatform
402   * @since 10
403   */
404  /**
405   * Obtains a {@link Preferences} instance matching a specified preferences file name.
406   * <p>The {@link references} instance loads all data of the preferences file and
407   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
408   *
409   * @param { Context } context - Indicates the context of application or capability.
410   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
411   * @returns { Promise<Preferences> } The {@link Preferences} instance matching the specified preferences file name.
412   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
413   *                                                                   2. Incorrect parameter types;
414   *                                                                   3. Parameter verification failed.
415   * @throws { BusinessError } 801 - Capability not supported.
416   * @throws { BusinessError } 15500000 - Inner error.
417   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
418   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
419   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
420   * @crossplatform
421   * @atomicservice
422   * @since 11
423   */
424  function getPreferences(context: Context, options: Options): Promise<Preferences>;
425
426  /**
427   * Obtains a {@link Preferences} instance matching a specified preferences file name.
428   * This interface is executed synchronously.
429   * <p>The {@link references} instance loads all data of the preferences file and
430   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
431   *
432   * @param { Context } context - Indicates the context of application or capability.
433   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
434   * @returns { Preferences } The {@link Preferences} instance matching the specified preferences file name.
435   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
436   *                                                                   2. Incorrect parameter types;
437   *                                                                   3. Parameter verification failed.
438   * @throws { BusinessError } 801 - Capability not supported.
439   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
440   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
441   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
442   * @crossplatform
443   * @since 10
444   */
445  /**
446   * Obtains a {@link Preferences} instance matching a specified preferences file name.
447   * This interface is executed synchronously.
448   * <p>The {@link references} instance loads all data of the preferences file and
449   * resides in the memory. You can use removePreferencesFromCache to remove the instance from the memory.
450   *
451   * @param { Context } context - Indicates the context of application or capability.
452   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
453   * @returns { Preferences } The {@link Preferences} instance matching the specified preferences file name.
454   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
455   *                                                                   2. Incorrect parameter types;
456   *                                                                   3. Parameter verification failed.
457   * @throws { BusinessError } 801 - Capability not supported.
458   * @throws { BusinessError } 15500000 - Inner error.
459   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
460   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
461   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
462   * @crossplatform
463   * @atomicservice
464   * @since 11
465   */
466  function getPreferencesSync(context: Context, options: Options): Preferences;
467
468  /**
469   * check the {@link StorageType} type is supported or not on current system.
470   * @param { StorageType } type - Indicates storage type which want to check.
471   * @returns { boolean } a boolean value indicates this system support the type or not.
472   * @throws { BusinessError } 401 - Parameter error. Possible causes: Incorrect parameter types
473   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
474   * @atomicservice
475   * @since 18
476   */
477  function isStorageTypeSupported(type: StorageType): boolean;
478  /**
479   * Deletes a {@link Preferences} instance matching a specified preferences file name
480   * from the cache which is performed by removePreferencesFromCache and deletes the
481   * preferences file.
482   * <p>When deleting the {@link Preferences} instance, you must release all references
483   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
484   * will occur.
485   *
486   * @param { Context } context - Indicates the context of application or capability.
487   * @param { string } name - Indicates the preferences file name.
488   * @param { AsyncCallback<void> } callback - Indicates the callback function.
489   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
490   *                                                                   2. Incorrect parameter types;
491   *                                                                   3. Parameter verification failed.
492   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
493   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
494   * @since 9
495   */
496  /**
497   * Deletes a {@link Preferences} instance matching a specified preferences file name
498   * from the cache which is performed by removePreferencesFromCache and deletes the
499   * preferences file.
500   * <p>When deleting the {@link Preferences} instance, you must release all references
501   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
502   * will occur.
503   *
504   * @param { Context } context - Indicates the context of application or capability.
505   * @param { string } name - Indicates the preferences file name.
506   * @param { AsyncCallback<void> } callback - Indicates the callback function.
507   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
508   *                                                                   2. Incorrect parameter types;
509   *                                                                   3. Parameter verification failed.
510   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
511   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
512   * @crossplatform
513   * @since 10
514   */
515  /**
516   * Deletes a {@link Preferences} instance matching a specified preferences file name
517   * from the cache which is performed by removePreferencesFromCache and deletes the
518   * preferences file.
519   * <p>When deleting the {@link Preferences} instance, you must release all references
520   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
521   * will occur.
522   *
523   * @param { Context } context - Indicates the context of application or capability.
524   * @param { string } name - Indicates the preferences file name.
525   * @param { AsyncCallback<void> } callback - Indicates the callback function.
526   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
527   *                                                                   2. Incorrect parameter types;
528   *                                                                   3. Parameter verification failed.
529   * @throws { BusinessError } 15500000 - Inner error.
530   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
531   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
532   * @crossplatform
533   * @atomicservice
534   * @since 11
535   */
536  function deletePreferences(context: Context, name: string, callback: AsyncCallback<void>): void;
537
538  /**
539   * Deletes a {@link Preferences} instance matching a specified preferences file name
540   * from the cache which is performed by removePreferencesFromCache and deletes the
541   * preferences file.
542   * <p>When deleting the {@link Preferences} instance, you must release all references
543   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
544   * will occur.
545   *
546   * @param { Context } context - Indicates the context of application or capability.
547   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
548   * @param { AsyncCallback<void> } callback - Indicates the callback function.
549   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
550   *                                                                   2. Incorrect parameter types;
551   *                                                                   3. Parameter verification failed.
552   * @throws { BusinessError } 801 - Capability not supported.
553   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
554   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
555   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
556   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
557   * @crossplatform
558   * @since 10
559   */
560  /**
561   * Deletes a {@link Preferences} instance matching a specified preferences file name
562   * from the cache which is performed by removePreferencesFromCache and deletes the
563   * preferences file.
564   * <p>When deleting the {@link Preferences} instance, you must release all references
565   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
566   * will occur.
567   *
568   * @param { Context } context - Indicates the context of application or capability.
569   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
570   * @param { AsyncCallback<void> } callback - Indicates the callback function.
571   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
572   *                                                                   2. Incorrect parameter types;
573   *                                                                   3. Parameter verification failed.
574   * @throws { BusinessError } 801 - Capability not supported.
575   * @throws { BusinessError } 15500000 - Inner error.
576   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
577   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
578   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
579   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
580   * @crossplatform
581   * @atomicservice
582   * @since 11
583   */
584  function deletePreferences(context: Context, options: Options, callback: AsyncCallback<void>): void;
585
586  /**
587   * Deletes a {@link Preferences} instance matching a specified preferences file name
588   * from the cache which is performed by removePreferencesFromCache and deletes the
589   * preferences file.
590   * <p>When deleting the {@link Preferences} instance, you must release all references
591   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
592   * will occur.
593   *
594   * @param { Context } context - Indicates the context of application or capability.
595   * @param { string } name - Indicates the preferences file name.
596   * @returns { Promise<void> } A promise object.
597   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
598   *                                                                   2. Incorrect parameter types;
599   *                                                                   3. Parameter verification failed.
600   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
601   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
602   * @since 9
603   */
604  /**
605   * Deletes a {@link Preferences} instance matching a specified preferences file name
606   * from the cache which is performed by removePreferencesFromCache and deletes the
607   * preferences file.
608   * <p>When deleting the {@link Preferences} instance, you must release all references
609   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
610   * will occur.
611   *
612   * @param { Context } context - Indicates the context of application or capability.
613   * @param { string } name - Indicates the preferences file name.
614   * @returns { Promise<void> } A promise object.
615   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
616   *                                                                   2. Incorrect parameter types;
617   *                                                                   3. Parameter verification failed.
618   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
619   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
620   * @crossplatform
621   * @since 10
622   */
623  /**
624   * Deletes a {@link Preferences} instance matching a specified preferences file name
625   * from the cache which is performed by removePreferencesFromCache and deletes the
626   * preferences file.
627   * <p>When deleting the {@link Preferences} instance, you must release all references
628   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
629   * will occur.
630   *
631   * @param { Context } context - Indicates the context of application or capability.
632   * @param { string } name - Indicates the preferences file name.
633   * @returns { Promise<void> } A promise object.
634   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
635   *                                                                   2. Incorrect parameter types;
636   *                                                                   3. Parameter verification failed.
637   * @throws { BusinessError } 15500000 - Inner error.
638   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
639   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
640   * @crossplatform
641   * @atomicservice
642   * @since 11
643   */
644  function deletePreferences(context: Context, name: string): Promise<void>;
645
646  /**
647   * Deletes a {@link Preferences} instance matching a specified preferences file name
648   * from the cache which is performed by removePreferencesFromCache and deletes the
649   * preferences file.
650   * <p>When deleting the {@link Preferences} instance, you must release all references
651   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
652   * will occur.
653   *
654   * @param { Context } context - Indicates the context of application or capability.
655   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
656   * @returns { Promise<void> } A promise object.
657   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
658   *                                                                   2. Incorrect parameter types;
659   *                                                                   3. Parameter verification failed.
660   * @throws { BusinessError } 801 - Capability not supported.
661   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
662   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
663   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
664   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
665   * @crossplatform
666   * @since 10
667   */
668  /**
669   * Deletes a {@link Preferences} instance matching a specified preferences file name
670   * from the cache which is performed by removePreferencesFromCache and deletes the
671   * preferences file.
672   * <p>When deleting the {@link Preferences} instance, you must release all references
673   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
674   * will occur.
675   *
676   * @param { Context } context - Indicates the context of application or capability.
677   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
678   * @returns { Promise<void> } A promise object.
679   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
680   *                                                                   2. Incorrect parameter types;
681   *                                                                   3. Parameter verification failed.
682   * @throws { BusinessError } 801 - Capability not supported.
683   * @throws { BusinessError } 15500000 - Inner error.
684   * @throws { BusinessError } 15500010 - Failed to delete the user preferences persistence file.
685   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
686   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
687   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
688   * @crossplatform
689   * @atomicservice
690   * @since 11
691   */
692  function deletePreferences(context: Context, options: Options): Promise<void>;
693
694  /**
695   * Deletes a {@link Preferences} instance matching a specified preferences file name
696   * from the cache.
697   * <p>When deleting the {@link Preferences} instance, you must release all references
698   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
699   * will occur.
700   *
701   * @param { Context } context - Indicates the context of application or capability.
702   * @param { string } name - Indicates the preferences file name.
703   * @param { AsyncCallback<void> } callback - Indicates the callback function.
704   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
705   *                                                                   2. Incorrect parameter types;
706   *                                                                   3. Parameter verification failed.
707   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
708   * @since 9
709   */
710  /**
711   * Deletes a {@link Preferences} instance matching a specified preferences file name
712   * from the cache.
713   * <p>When deleting the {@link Preferences} instance, you must release all references
714   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
715   * will occur.
716   *
717   * @param { Context } context - Indicates the context of application or capability.
718   * @param { string } name - Indicates the preferences file name.
719   * @param { AsyncCallback<void> } callback - Indicates the callback function.
720   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
721   *                                                                   2. Incorrect parameter types;
722   *                                                                   3. Parameter verification failed.
723   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
724   * @crossplatform
725   * @since 10
726   */
727  /**
728   * Deletes a {@link Preferences} instance matching a specified preferences file name
729   * from the cache.
730   * <p>When deleting the {@link Preferences} instance, you must release all references
731   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
732   * will occur.
733   *
734   * @param { Context } context - Indicates the context of application or capability.
735   * @param { string } name - Indicates the preferences file name.
736   * @param { AsyncCallback<void> } callback - Indicates the callback function.
737   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
738   *                                                                   2. Incorrect parameter types;
739   *                                                                   3. Parameter verification failed.
740   * @throws { BusinessError } 15500000 - Inner error.
741   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
742   * @crossplatform
743   * @atomicservice
744   * @since 11
745   */
746  function removePreferencesFromCache(context: Context, name: string, callback: AsyncCallback<void>): void;
747
748  /**
749   * Deletes a {@link Preferences} instance matching a specified preferences file name
750   * from the cache.
751   * <p>When deleting the {@link Preferences} instance, you must release all references
752   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
753   * will occur.
754   *
755   * @param { Context } context - Indicates the context of application or capability.
756   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
757   * @param { AsyncCallback<void> } callback - Indicates the callback function.
758   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
759   *                                                                   2. Incorrect parameter types;
760   *                                                                   3. Parameter verification failed.
761   * @throws { BusinessError } 801 - Capability not supported.
762   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
763   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
764   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
765   * @crossplatform
766   * @since 10
767   */
768  /**
769   * Deletes a {@link Preferences} instance matching a specified preferences file name
770   * from the cache.
771   * <p>When deleting the {@link Preferences} instance, you must release all references
772   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
773   * will occur.
774   *
775   * @param { Context } context - Indicates the context of application or capability.
776   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
777   * @param { AsyncCallback<void> } callback - Indicates the callback function.
778   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
779   *                                                                   2. Incorrect parameter types;
780   *                                                                   3. Parameter verification failed.
781   * @throws { BusinessError } 801 - Capability not supported.
782   * @throws { BusinessError } 15500000 - Inner error.
783   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
784   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
785   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
786   * @crossplatform
787   * @atomicservice
788   * @since 11
789   */
790  function removePreferencesFromCache(context: Context, options: Options, callback: AsyncCallback<void>): void;
791
792  /**
793   * Deletes a {@link Preferences} instance matching a specified preferences file name
794   * from the cache.
795   * <p>When deleting the {@link Preferences} instance, you must release all references
796   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
797   * will occur.
798   *
799   * @param { Context } context - Indicates the context of application or capability.
800   * @param { string } name - Indicates the preferences file name.
801   * @returns { Promise<void> } A promise object.
802   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
803   *                                                                   2. Incorrect parameter types;
804   *                                                                   3. Parameter verification failed.
805   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
806   * @since 9
807   */
808  /**
809   * Deletes a {@link Preferences} instance matching a specified preferences file name
810   * from the cache.
811   * <p>When deleting the {@link Preferences} instance, you must release all references
812   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
813   * will occur.
814   *
815   * @param { Context } context - Indicates the context of application or capability.
816   * @param { string } name - Indicates the preferences file name.
817   * @returns { Promise<void> } A promise object.
818   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
819   *                                                                   2. Incorrect parameter types;
820   *                                                                   3. Parameter verification failed.
821   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
822   * @crossplatform
823   * @since 10
824   */
825  /**
826   * Deletes a {@link Preferences} instance matching a specified preferences file name
827   * from the cache.
828   * <p>When deleting the {@link Preferences} instance, you must release all references
829   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
830   * will occur.
831   *
832   * @param { Context } context - Indicates the context of application or capability.
833   * @param { string } name - Indicates the preferences file name.
834   * @returns { Promise<void> } A promise object.
835   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
836   *                                                                   2. Incorrect parameter types;
837   *                                                                   3. Parameter verification failed.
838   * @throws { BusinessError } 15500000 - Inner error.
839   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
840   * @crossplatform
841   * @atomicservice
842   * @since 11
843   */
844  function removePreferencesFromCache(context: Context, name: string): Promise<void>;
845
846  /**
847   * Deletes a {@link Preferences} instance matching a specified preferences file name
848   * from the cache.
849   * <p>When deleting the {@link Preferences} instance, you must release all references
850   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
851   * will occur.
852   *
853   * @param { Context } context - Indicates the context of application or capability.
854   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
855   * @returns { Promise<void> } A promise object.
856   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
857   *                                                                   2. Incorrect parameter types;
858   *                                                                   3. Parameter verification failed.
859   * @throws { BusinessError } 801 - Capability not supported.
860   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
861   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
862   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
863   * @crossplatform
864   * @since 10
865   */
866  /**
867   * Deletes a {@link Preferences} instance matching a specified preferences file name
868   * from the cache.
869   * <p>When deleting the {@link Preferences} instance, you must release all references
870   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
871   * will occur.
872   *
873   * @param { Context } context - Indicates the context of application or capability.
874   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
875   * @returns { Promise<void> } A promise object.
876   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
877   *                                                                   2. Incorrect parameter types;
878   *                                                                   3. Parameter verification failed.
879   * @throws { BusinessError } 801 - Capability not supported.
880   * @throws { BusinessError } 15500000 - Inner error.
881   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
882   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
883   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
884   * @crossplatform
885   * @atomicservice
886   * @since 11
887   */
888  function removePreferencesFromCache(context: Context, options: Options): Promise<void>;
889
890  /**
891   * Deletes a {@link Preferences} instance matching a specified preferences file name
892   * from the cache. This interface is executed synchronously.
893   * <p>When deleting the {@link Preferences} instance, you must release all references
894   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
895   * will occur.
896   *
897   * @param { Context } context - Indicates the context of application or capability.
898   * @param { string } name - Indicates the preferences file name.
899   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
900   *                                                                   2. Incorrect parameter types;
901   *                                                                   3. Parameter verification failed.
902   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
903   * @crossplatform
904   * @since 10
905   */
906  /**
907   * Deletes a {@link Preferences} instance matching a specified preferences file name
908   * from the cache. This interface is executed synchronously.
909   * <p>When deleting the {@link Preferences} instance, you must release all references
910   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
911   * will occur.
912   *
913   * @param { Context } context - Indicates the context of application or capability.
914   * @param { string } name - Indicates the preferences file name.
915   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
916   *                                                                   2. Incorrect parameter types;
917   *                                                                   3. Parameter verification failed.
918   * @throws { BusinessError } 15500000 - Inner error.
919   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
920   * @crossplatform
921   * @atomicservice
922   * @since 11
923   */
924  function removePreferencesFromCacheSync(context: Context, name: string): void;
925
926  /**
927   * Deletes a {@link Preferences} instance matching a specified preferences file name
928   * from the cache. This interface is executed synchronously.
929   * <p>When deleting the {@link Preferences} instance, you must release all references
930   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
931   * will occur.
932   *
933   * @param { Context } context - Indicates the context of application or capability.
934   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
935   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
936   *                                                                   2. Incorrect parameter types;
937   *                                                                   3. Parameter verification failed.
938   * @throws { BusinessError } 801 - Capability not supported.
939   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
940   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
941   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
942   * @crossplatform
943   * @since 10
944   */
945  /**
946   * Deletes a {@link Preferences} instance matching a specified preferences file name
947   * from the cache. This interface is executed synchronously.
948   * <p>When deleting the {@link Preferences} instance, you must release all references
949   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, data inconsistency
950   * will occur.
951   *
952   * @param { Context } context - Indicates the context of application or capability.
953   * @param { Options } options - Indicates the {@link Options} option of preferences file position.
954   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
955   *                                                                   2. Incorrect parameter types;
956   *                                                                   3. Parameter verification failed.
957   * @throws { BusinessError } 801 - Capability not supported.
958   * @throws { BusinessError } 15500000 - Inner error.
959   * @throws { BusinessError } 15501001 - The operations is supported in stage mode only.
960   * @throws { BusinessError } 15501002 - Invalid dataGroupId.
961   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
962   * @crossplatform
963   * @atomicservice
964   * @since 11
965   */
966  function removePreferencesFromCacheSync(context: Context, options: Options): void;
967
968  /**
969   * Provides interfaces to obtain and modify preferences data.
970   * <p>The preferences data is stored in a file, which matches only one {@link Preferences} instance in the memory.
971   * You can use getPreferences to obtain the {@link Preferences} instance matching
972   * the file that stores preferences data, and use movePreferencesFromCache
973   * to remove the {@link Preferences} instance from the memory.
974   *
975   * @interface Preferences
976   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
977   * @since 9
978   */
979  /**
980   * Provides interfaces to obtain and modify preferences data.
981   * <p>The preferences data is stored in a file, which matches only one {@link Preferences} instance in the memory.
982   * You can use getPreferences to obtain the {@link Preferences} instance matching
983   * the file that stores preferences data, and use movePreferencesFromCache
984   * to remove the {@link Preferences} instance from the memory.
985   *
986   * @interface Preferences
987   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
988   * @crossplatform
989   * @since 10
990   */
991  /**
992   * Provides interfaces to obtain and modify preferences data.
993   * <p>The preferences data is stored in a file, which matches only one {@link Preferences} instance in the memory.
994   * You can use getPreferences to obtain the {@link Preferences} instance matching
995   * the file that stores preferences data, and use movePreferencesFromCache
996   * to remove the {@link Preferences} instance from the memory.
997   *
998   * @interface Preferences
999   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1000   * @crossplatform
1001   * @atomicservice
1002   * @since 11
1003   */
1004  interface Preferences {
1005    /**
1006     * Obtains the value of a preferences in the ValueType format.
1007     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1008     *
1009     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1010     *         <tt>MAX_KEY_LENGTH</tt>.
1011     * @param { ValueType } defValue - Indicates the default value to return.
1012     * @param { AsyncCallback<ValueType> } callback - The value matching the specified key if it is found;
1013     *        returns the default value otherwise.
1014     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1015     *                                                                   2. Incorrect parameter types;
1016     *                                                                   3. Parameter verification failed.
1017     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1018     * @since 9
1019     */
1020    /**
1021     * Obtains the value of a preferences in the ValueType format.
1022     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1023     *
1024     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1025     *         <tt>MAX_KEY_LENGTH</tt>.
1026     * @param { ValueType } defValue - Indicates the default value to return.
1027     * @param { AsyncCallback<ValueType> } callback - The value matching the specified key if it is found;
1028     *        returns the default value otherwise.
1029     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1030     *                                                                   2. Incorrect parameter types;
1031     *                                                                   3. Parameter verification failed.
1032     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1033     * @crossplatform
1034     * @since 10
1035     */
1036    /**
1037     * Obtains the value of a preferences in the ValueType format.
1038     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1039     *
1040     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1041     *         <tt>MAX_KEY_LENGTH</tt>.
1042     * @param { ValueType } defValue - Indicates the default value to return.
1043     * @param { AsyncCallback<ValueType> } callback - The value matching the specified key if it is found;
1044     *        returns the default value otherwise.
1045     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1046     *                                                                   2. Incorrect parameter types;
1047     *                                                                   3. Parameter verification failed.
1048     * @throws { BusinessError } 15500000 - Inner error.
1049     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1050     * @crossplatform
1051     * @atomicservice
1052     * @since 11
1053     */
1054    get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void;
1055
1056    /**
1057     * Obtains the value of a preferences in the ValueType format.
1058     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1059     *
1060     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1061     *         <tt>MAX_KEY_LENGTH</tt>.
1062     * @param { ValueType } defValue - Indicates the default value to return.
1063     * @returns { Promise<ValueType> } The value matching the specified key if it is found;
1064     *          returns the default value otherwise.
1065     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1066     *                                                                   2. Incorrect parameter types;
1067     *                                                                   3. Parameter verification failed.
1068     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1069     * @since 9
1070     */
1071    /**
1072     * Obtains the value of a preferences in the ValueType format.
1073     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1074     *
1075     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1076     *         <tt>MAX_KEY_LENGTH</tt>.
1077     * @param { ValueType } defValue - Indicates the default value to return.
1078     * @returns { Promise<ValueType> } The value matching the specified key if it is found;
1079     *          returns the default value otherwise.
1080     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1081     *                                                                   2. Incorrect parameter types;
1082     *                                                                   3. Parameter verification failed.
1083     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1084     * @crossplatform
1085     * @since 10
1086     */
1087    /**
1088     * Obtains the value of a preferences in the ValueType format.
1089     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1090     *
1091     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1092     *         <tt>MAX_KEY_LENGTH</tt>.
1093     * @param { ValueType } defValue - Indicates the default value to return.
1094     * @returns { Promise<ValueType> } The value matching the specified key if it is found;
1095     *          returns the default value otherwise.
1096     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1097     *                                                                   2. Incorrect parameter types;
1098     *                                                                   3. Parameter verification failed.
1099     * @throws { BusinessError } 15500000 - Inner error.
1100     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1101     * @crossplatform
1102     * @atomicservice
1103     * @since 11
1104     */
1105    get(key: string, defValue: ValueType): Promise<ValueType>;
1106
1107    /**
1108     * Obtains the value of a preferences in the ValueType format. This interface is executed synchronously.
1109     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1110     *
1111     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1112     *         <tt>MAX_KEY_LENGTH</tt>.
1113     * @param { ValueType } defValue - Indicates the default value to return.
1114     * @returns { ValueType } The value matching the specified key if it is found;
1115     *          returns the default value otherwise.
1116     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1117     *                                                                   2. Incorrect parameter types;
1118     *                                                                   3. Parameter verification failed.
1119     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1120     * @crossplatform
1121     * @since 10
1122     */
1123    /**
1124     * Obtains the value of a preferences in the ValueType format. This interface is executed synchronously.
1125     * <p>If the value is {@code null} or not in the ValueType format, the default value is returned.
1126     *
1127     * @param { string } key - Indicates the key of the preferences. It cannot be {@code null} or empty.
1128     *         <tt>MAX_KEY_LENGTH</tt>.
1129     * @param { ValueType } defValue - Indicates the default value to return.
1130     * @returns { ValueType } The value matching the specified key if it is found;
1131     *          returns the default value otherwise.
1132     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1133     *                                                                   2. Incorrect parameter types;
1134     *                                                                   3. Parameter verification failed.
1135     * @throws { BusinessError } 15500000 - Inner error.
1136     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1137     * @crossplatform
1138     * @atomicservice
1139     * @since 11
1140     */
1141    getSync(key: string, defValue: ValueType): ValueType;
1142
1143    /**
1144     * Obtains all the keys and values of a preferences in an object.
1145     *
1146     * @param { AsyncCallback<Object> } callback - The values and keys in an object.
1147     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1148     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1149     * @since 9
1150     */
1151    /**
1152     * Obtains all the keys and values of a preferences in an object.
1153     *
1154     * @param { AsyncCallback<Object> } callback - The values and keys in an object.
1155     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1156     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1157     * @crossplatform
1158     * @since 10
1159     */
1160    /**
1161     * Obtains all the keys and values of a preferences in an object.
1162     *
1163     * @param { AsyncCallback<Object> } callback - The values and keys in an object.
1164     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1165     * @throws { BusinessError } 15500000 - Inner error.
1166     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1167     * @crossplatform
1168     * @atomicservice
1169     * @since 11
1170     */
1171    getAll(callback: AsyncCallback<Object>): void;
1172
1173    /**
1174     * Obtains all the keys and values of a preferences in an object.
1175     *
1176     * @returns { Promise<Object> } The values and keys in an object.
1177     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1178     * @since 9
1179     */
1180    /**
1181     * Obtains all the keys and values of a preferences in an object.
1182     *
1183     * @returns { Promise<Object> } The values and keys in an object.
1184     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1185     * @crossplatform
1186     * @since 10
1187     */
1188    /**
1189     * Obtains all the keys and values of a preferences in an object.
1190     *
1191     * @returns { Promise<Object> } The values and keys in an object.
1192     * @throws { BusinessError } 15500000 - Inner error.
1193     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1194     * @crossplatform
1195     * @atomicservice
1196     * @since 11
1197     */
1198    getAll(): Promise<Object>;
1199
1200    /**
1201     * Obtains all the keys and values of a preferences in an object.  This interface
1202     * is executed synchronously.
1203     *
1204     * @returns { Object } The values and keys in an object.
1205     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1206     * @crossplatform
1207     * @since 10
1208     */
1209    /**
1210     * Obtains all the keys and values of a preferences in an object.  This interface
1211     * is executed synchronously.
1212     *
1213     * @returns { Object } The values and keys in an object.
1214     * @throws { BusinessError } 15500000 - Inner error.
1215     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1216     * @crossplatform
1217     * @atomicservice
1218     * @since 11
1219     */
1220    getAllSync(): Object;
1221
1222    /**
1223     * Checks whether the {@link Preferences} object contains a preferences matching a specified key.
1224     *
1225     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1226     *         <tt>MAX_KEY_LENGTH</tt>.
1227     * @param { AsyncCallback<boolean> } callback - {@code true} if the {@link Preferences} object contains a preferences
1228     *         with the specified key;returns {@code false} otherwise.
1229     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1230     *                                                                   2. Incorrect parameter types;
1231     *                                                                   3. Parameter verification failed.
1232     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1233     * @since 9
1234     */
1235    /**
1236     * Checks whether the {@link Preferences} object contains a preferences matching a specified key.
1237     *
1238     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1239     *         <tt>MAX_KEY_LENGTH</tt>.
1240     * @param { AsyncCallback<boolean> } callback - {@code true} if the {@link Preferences} object contains a preferences
1241     *         with the specified key;returns {@code false} otherwise.
1242     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1243     *                                                                   2. Incorrect parameter types;
1244     *                                                                   3. Parameter verification failed.
1245     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1246     * @crossplatform
1247     * @since 10
1248     */
1249    /**
1250     * Checks whether the {@link Preferences} object contains a preferences matching a specified key.
1251     *
1252     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1253     *         <tt>MAX_KEY_LENGTH</tt>.
1254     * @param { AsyncCallback<boolean> } callback - {@code true} if the {@link Preferences} object contains a preferences
1255     *         with the specified key;returns {@code false} otherwise.
1256     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1257     *                                                                   2. Incorrect parameter types;
1258     *                                                                   3. Parameter verification failed.
1259     * @throws { BusinessError } 15500000 - Inner error.
1260     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1261     * @crossplatform
1262     * @atomicservice
1263     * @since 11
1264     */
1265    has(key: string, callback: AsyncCallback<boolean>): void;
1266
1267    /**
1268     * Checks whether the {@link Preferences} object contains a preferences matching a specified key.
1269     *
1270     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1271     *         <tt>MAX_KEY_LENGTH</tt>.
1272     * @returns { Promise<boolean> } {@code true} if the {@link Preferences} object contains
1273     *         a preferences with the specified key; returns {@code false} otherwise.
1274     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1275     *                                                                   2. Incorrect parameter types;
1276     *                                                                   3. Parameter verification failed.
1277     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1278     * @since 9
1279     */
1280    /**
1281     * Checks whether the {@link Preferences} object contains a preferences matching a specified key.
1282     *
1283     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1284     *         <tt>MAX_KEY_LENGTH</tt>.
1285     * @returns { Promise<boolean> } {@code true} if the {@link Preferences} object contains
1286     *         a preferences with the specified key; returns {@code false} otherwise.
1287     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1288     *                                                                   2. Incorrect parameter types;
1289     *                                                                   3. Parameter verification failed.
1290     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1291     * @crossplatform
1292     * @since 10
1293     */
1294    /**
1295     * Checks whether the {@link Preferences} object contains a preferences matching a specified key.
1296     *
1297     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1298     *         <tt>MAX_KEY_LENGTH</tt>.
1299     * @returns { Promise<boolean> } {@code true} if the {@link Preferences} object contains
1300     *         a preferences with the specified key; returns {@code false} otherwise.
1301     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1302     *                                                                   2. Incorrect parameter types;
1303     *                                                                   3. Parameter verification failed.
1304     * @throws { BusinessError } 15500000 - Inner error.
1305     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1306     * @crossplatform
1307     * @atomicservice
1308     * @since 11
1309     */
1310    has(key: string): Promise<boolean>;
1311
1312    /**
1313     * Checks whether the {@link Preferences} object contains a preferences matching a specified key. This interface
1314     * is executed synchronously.
1315     *
1316     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1317     *         <tt>MAX_KEY_LENGTH</tt>.
1318     * @returns { boolean } {@code true} if the {@link Preferences} object contains
1319     *         a preferences with the specified key; returns {@code false} otherwise.
1320     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1321     *                                                                   2. Incorrect parameter types;
1322     *                                                                   3. Parameter verification failed.
1323     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1324     * @crossplatform
1325     * @since 10
1326     */
1327    /**
1328     * Checks whether the {@link Preferences} object contains a preferences matching a specified key. This interface
1329     * is executed synchronously.
1330     *
1331     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1332     *         <tt>MAX_KEY_LENGTH</tt>.
1333     * @returns { boolean } {@code true} if the {@link Preferences} object contains
1334     *         a preferences with the specified key; returns {@code false} otherwise.
1335     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1336     *                                                                   2. Incorrect parameter types;
1337     *                                                                   3. Parameter verification failed.
1338     * @throws { BusinessError } 15500000 - Inner error.
1339     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1340     * @crossplatform
1341     * @atomicservice
1342     * @since 11
1343     */
1344    hasSync(key: string): boolean;
1345
1346    /**
1347     * Sets an int value for the key in the {@link Preferences} object.
1348     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1349     * file.
1350     *
1351     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1352     *        <tt>MAX_KEY_LENGTH</tt>.
1353     * @param { ValueType } value - Indicates the value of the preferences.
1354     *        <tt>MAX_VALUE_LENGTH</tt>.
1355     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1356     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1357     *                                                                   2. Incorrect parameter types;
1358     *                                                                   3. Parameter verification failed.
1359     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1360     * @since 9
1361     */
1362    /**
1363     * Sets an int value for the key in the {@link Preferences} object.
1364     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1365     * file.
1366     *
1367     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1368     *        <tt>MAX_KEY_LENGTH</tt>.
1369     * @param { ValueType } value - Indicates the value of the preferences.
1370     *        <tt>MAX_VALUE_LENGTH</tt>.
1371     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1372     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1373     *                                                                   2. Incorrect parameter types;
1374     *                                                                   3. Parameter verification failed.
1375     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1376     * @crossplatform
1377     * @since 10
1378     */
1379    /**
1380     * Sets an int value for the key in the {@link Preferences} object.
1381     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1382     * file.
1383     *
1384     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1385     *        <tt>MAX_KEY_LENGTH</tt>.
1386     * @param { ValueType } value - Indicates the value of the preferences.
1387     *        <tt>MAX_VALUE_LENGTH</tt>.
1388     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1389     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1390     *                                                                   2. Incorrect parameter types;
1391     *                                                                   3. Parameter verification failed.
1392     * @throws { BusinessError } 15500000 - Inner error.
1393     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1394     * @crossplatform
1395     * @atomicservice
1396     * @since 11
1397     */
1398    put(key: string, value: ValueType, callback: AsyncCallback<void>): void;
1399
1400    /**
1401     * Sets an int value for the key in the {@link Preferences} object.
1402     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1403     * file.
1404     *
1405     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1406     *        <tt>MAX_KEY_LENGTH</tt>.
1407     * @param { ValueType } value - Indicates the value of the preferences.
1408     *        <tt>MAX_VALUE_LENGTH</tt>.
1409     * @returns { Promise<void> } A promise object.
1410     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1411     *                                                                   2. Incorrect parameter types;
1412     *                                                                   3. Parameter verification failed.
1413     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1414     * @since 9
1415     */
1416    /**
1417     * Sets an int value for the key in the {@link Preferences} object.
1418     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1419     * file.
1420     *
1421     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1422     *        <tt>MAX_KEY_LENGTH</tt>.
1423     * @param { ValueType } value - Indicates the value of the preferences.
1424     *        <tt>MAX_VALUE_LENGTH</tt>.
1425     * @returns { Promise<void> } A promise object.
1426     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1427     *                                                                   2. Incorrect parameter types;
1428     *                                                                   3. Parameter verification failed.
1429     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1430     * @crossplatform
1431     * @since 10
1432     */
1433    /**
1434     * Sets an int value for the key in the {@link Preferences} object.
1435     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1436     * file.
1437     *
1438     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1439     *        <tt>MAX_KEY_LENGTH</tt>.
1440     * @param { ValueType } value - Indicates the value of the preferences.
1441     *        <tt>MAX_VALUE_LENGTH</tt>.
1442     * @returns { Promise<void> } A promise object.
1443     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1444     *                                                                   2. Incorrect parameter types;
1445     *                                                                   3. Parameter verification failed.
1446     * @throws { BusinessError } 15500000 - Inner error.
1447     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1448     * @crossplatform
1449     * @atomicservice
1450     * @since 11
1451     */
1452    put(key: string, value: ValueType): Promise<void>;
1453
1454    /**
1455     * Sets an int value for the key in the {@link Preferences} object. This interface is executed synchronously.
1456     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1457     * file.
1458     *
1459     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1460     *        <tt>MAX_KEY_LENGTH</tt>.
1461     * @param { ValueType } value - Indicates the value of the preferences.
1462     *        <tt>MAX_VALUE_LENGTH</tt>.
1463     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1464     *                                                                   2. Incorrect parameter types;
1465     *                                                                   3. Parameter verification failed.
1466     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1467     * @crossplatform
1468     * @since 10
1469     */
1470    /**
1471     * Sets an int value for the key in the {@link Preferences} object. This interface is executed synchronously.
1472     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1473     * file.
1474     *
1475     * @param { string } key - Indicates the key of the preferences to modify. It cannot be {@code null} or empty.
1476     *        <tt>MAX_KEY_LENGTH</tt>.
1477     * @param { ValueType } value - Indicates the value of the preferences.
1478     *        <tt>MAX_VALUE_LENGTH</tt>.
1479     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1480     *                                                                   2. Incorrect parameter types;
1481     *                                                                   3. Parameter verification failed.
1482     * @throws { BusinessError } 15500000 - Inner error.
1483     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1484     * @crossplatform
1485     * @atomicservice
1486     * @since 11
1487     */
1488    putSync(key: string, value: ValueType): void;
1489
1490    /**
1491     * Deletes the preferences with a specified key from the {@link Preferences} object.
1492     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1493     * file.
1494     *
1495     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1496     *        <tt>MAX_KEY_LENGTH</tt>.
1497     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1498     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1499     *                                                                   2. Incorrect parameter types;
1500     *                                                                   3. Parameter verification failed.
1501     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1502     * @since 9
1503     */
1504    /**
1505     * Deletes the preferences with a specified key from the {@link Preferences} object.
1506     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1507     * file.
1508     *
1509     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1510     *        <tt>MAX_KEY_LENGTH</tt>.
1511     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1512     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1513     *                                                                   2. Incorrect parameter types;
1514     *                                                                   3. Parameter verification failed.
1515     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1516     * @crossplatform
1517     * @since 10
1518     */
1519    /**
1520     * Deletes the preferences with a specified key from the {@link Preferences} object.
1521     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1522     * file.
1523     *
1524     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1525     *        <tt>MAX_KEY_LENGTH</tt>.
1526     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1527     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1528     *                                                                   2. Incorrect parameter types;
1529     *                                                                   3. Parameter verification failed.
1530     * @throws { BusinessError } 15500000 - Inner error.
1531     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1532     * @crossplatform
1533     * @atomicservice
1534     * @since 11
1535     */
1536    delete(key: string, callback: AsyncCallback<void>): void;
1537
1538    /**
1539     * Deletes the preferences with a specified key from the {@link Preferences} object.
1540     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1541     * file.
1542     *
1543     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1544     *        <tt>MAX_KEY_LENGTH</tt>.
1545     * @returns { Promise<void> } A promise object.
1546     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1547     *                                                                   2. Incorrect parameter types;
1548     *                                                                   3. Parameter verification failed.
1549     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1550     * @since 9
1551     */
1552    /**
1553     * Deletes the preferences with a specified key from the {@link Preferences} object.
1554     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1555     * file.
1556     *
1557     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1558     *        <tt>MAX_KEY_LENGTH</tt>.
1559     * @returns { Promise<void> } A promise object.
1560     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1561     *                                                                   2. Incorrect parameter types;
1562     *                                                                   3. Parameter verification failed.
1563     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1564     * @crossplatform
1565     * @since 10
1566     */
1567    /**
1568     * Deletes the preferences with a specified key from the {@link Preferences} object.
1569     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the
1570     * file.
1571     *
1572     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1573     *        <tt>MAX_KEY_LENGTH</tt>.
1574     * @returns { Promise<void> } A promise object.
1575     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1576     *                                                                   2. Incorrect parameter types;
1577     *                                                                   3. Parameter verification failed.
1578     * @throws { BusinessError } 15500000 - Inner error.
1579     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1580     * @crossplatform
1581     * @atomicservice
1582     * @since 11
1583     */
1584    delete(key: string): Promise<void>;
1585
1586    /**
1587     * Deletes the preferences with a specified key from the {@link Preferences} object. This interface is
1588     * executed synchronously. <p>You can call the {@link #flush} method to save the {@link Preferences}
1589     * object to the file.
1590     *
1591     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1592     *        <tt>MAX_KEY_LENGTH</tt>.
1593     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1594     *                                                                   2. Incorrect parameter types;
1595     *                                                                   3. Parameter verification failed.
1596     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1597     * @crossplatform
1598     * @since 10
1599     */
1600    /**
1601     * Deletes the preferences with a specified key from the {@link Preferences} object. This interface is
1602     * executed synchronously. <p>You can call the {@link #flush} method to save the {@link Preferences}
1603     * object to the file.
1604     *
1605     * @param { string } key - Indicates the key of the preferences to delete. It cannot be {@code null} or empty.
1606     *        <tt>MAX_KEY_LENGTH</tt>.
1607     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1608     *                                                                   2. Incorrect parameter types;
1609     *                                                                   3. Parameter verification failed.
1610     * @throws { BusinessError } 15500000 - Inner error.
1611     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1612     * @crossplatform
1613     * @atomicservice
1614     * @since 11
1615     */
1616    deleteSync(key: string): void;
1617
1618    /**
1619     * Clears all preferences from the {@link Preferences} object.
1620     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1621     *
1622     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1623     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1624     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1625     * @since 9
1626     */
1627    /**
1628     * Clears all preferences from the {@link Preferences} object.
1629     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1630     *
1631     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1632     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1633     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1634     * @crossplatform
1635     * @since 10
1636     */
1637    /**
1638     * Clears all preferences from the {@link Preferences} object.
1639     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1640     *
1641     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1642     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1643     * @throws { BusinessError } 15500000 - Inner error.
1644     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1645     * @crossplatform
1646     * @atomicservice
1647     * @since 11
1648     */
1649    clear(callback: AsyncCallback<void>): void;
1650
1651    /**
1652     * Clears all preferences from the {@link Preferences} object.
1653     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1654     *
1655     * @returns { Promise<void> } A promise object.
1656     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1657     * @since 9
1658     */
1659    /**
1660     * Clears all preferences from the {@link Preferences} object.
1661     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1662     *
1663     * @returns { Promise<void> } A promise object.
1664     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1665     * @crossplatform
1666     * @since 10
1667     */
1668    /**
1669     * Clears all preferences from the {@link Preferences} object.
1670     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1671     *
1672     * @returns { Promise<void> } A promise object.
1673     * @throws { BusinessError } 15500000 - Inner error.
1674     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1675     * @crossplatform
1676     * @atomicservice
1677     * @since 11
1678     */
1679    clear(): Promise<void>;
1680
1681    /**
1682     * Clears all preferences from the {@link Preferences} object. This interface is executed synchronously.
1683     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1684     *
1685     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1686     * @crossplatform
1687     * @since 10
1688     */
1689    /**
1690     * Clears all preferences from the {@link Preferences} object. This interface is executed synchronously.
1691     * <p>You can call the {@link #flush} method to save the {@link Preferences} object to the file.
1692     *
1693     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1694     * @crossplatform
1695     * @atomicservice
1696     * @since 11
1697     */
1698    clearSync(): void;
1699
1700    /**
1701     * Asynchronously saves the {@link Preferences} object to the file.
1702     *
1703     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1704     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified;
1705     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1706     * @since 9
1707     */
1708    /**
1709     * Asynchronously saves the {@link Preferences} object to the file.
1710     *
1711     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1712     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified;
1713     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1714     * @crossplatform
1715     * @since 10
1716     */
1717    /**
1718     * Asynchronously saves the {@link Preferences} object to the file.
1719     *
1720     * @param { AsyncCallback<void> } callback - Indicates the callback function.
1721     * @throws { BusinessError } 401 - Parameter error. Mandatory parameters are left unspecified.
1722     * @throws { BusinessError } 15500000 - Inner error.
1723     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1724     * @crossplatform
1725     * @atomicservice
1726     * @since 11
1727     */
1728    flush(callback: AsyncCallback<void>): void;
1729
1730    /**
1731     * Asynchronously saves the {@link Preferences} object to the file.
1732     *
1733     * @returns { Promise<void> } A promise object.
1734     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1735     * @since 9
1736     */
1737    /**
1738     * Asynchronously saves the {@link Preferences} object to the file.
1739     *
1740     * @returns { Promise<void> } A promise object.
1741     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1742     * @crossplatform
1743     * @since 10
1744     */
1745    /**
1746     * Asynchronously saves the {@link Preferences} object to the file.
1747     *
1748     * @returns { Promise<void> } A promise object.
1749     * @throws { BusinessError } 15500000 - Inner error.
1750     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1751     * @crossplatform
1752     * @atomicservice
1753     * @since 11
1754     */
1755    flush(): Promise<void>;
1756
1757    /**
1758     * Saves the {@link Preferences} object to the file.
1759     *
1760     * @throws { BusinessError } 15500000 - Inner error.
1761     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1762     * @crossplatform
1763     * @atomicservice
1764     * @since 14
1765     */
1766    flushSync(): void;
1767
1768    /**
1769     * Registers an observer to listen for the change of a {@link Preferences} object.
1770     *
1771     * @param { 'change' } type - Indicates the callback when preferences changes.
1772     * @param { Callback<{ key: string }> } callback - Indicates the callback function.
1773     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1774     *                                                                   2. Incorrect parameter types;
1775     *                                                                   3. Parameter verification failed.
1776     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1777     * @since 9
1778     */
1779    /**
1780     * Registers an observer to listen for the change of a {@link Preferences} object.
1781     *
1782     * @param { 'change' } type - Indicates the callback when preferences changes.
1783     * @param { Function } callback - Indicates the callback function.
1784     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1785     *                                                                   2. Incorrect parameter types;
1786     *                                                                   3. Parameter verification failed.
1787     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1788     * @crossplatform
1789     * @since 10
1790     */
1791    /**
1792     * Registers an observer to listen for the change of a {@link Preferences} object.
1793     *
1794     * @param { 'change' } type - Indicates the callback when preferences changes.
1795     * @param { Callback<string> } callback - Indicates the callback function.
1796     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1797     *                                                                   2. Incorrect parameter types;
1798     *                                                                   3. Parameter verification failed.
1799     * @throws { BusinessError } 15500000 - Inner error.
1800     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1801     * @crossplatform
1802     * @atomicservice
1803     * @since 11
1804     */
1805    on(type: 'change', callback: Callback<string>): void;
1806
1807    /**
1808     * Registers an observer to listen for the change of a {@link Preferences} object.
1809     *
1810     * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes.
1811     * @param { Function } callback - Indicates the callback function.
1812     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1813     *                                                                   2. Incorrect parameter types;
1814     *                                                                   3. Parameter verification failed.
1815     * @throws { BusinessError } 15500019 - Failed to obtain the subscription service.
1816     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1817     * @since 10
1818     */
1819    /**
1820     * Registers an observer to listen for the change of a {@link Preferences} object.
1821     *
1822     * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes.
1823     * @param { Callback<string> } callback - Indicates the callback function.
1824     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1825     *                                                                   2. Incorrect parameter types;
1826     *                                                                   3. Parameter verification failed.
1827     * @throws { BusinessError } 15500000 - Inner error.
1828     * @throws { BusinessError } 15500019 - Failed to obtain the subscription service.
1829     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1830     * @atomicservice
1831     * @since 11
1832     */
1833    on(type: 'multiProcessChange', callback: Callback<string>): void;
1834
1835    /**
1836     * Registers an observer to listen for changes to the {@ link Preferences} object.
1837     *
1838     * @param { 'dataChange' } type - Indicates the type of the event to observe.
1839     * @param { Array<string> } keys - Indicates one or more keys to listen for.
1840     * @param { Callback<Record<string, ValueType>> } callback - Indicates the callback used to return the data change.
1841     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1842     *                                                                   2. Incorrect parameter types;
1843     *                                                                   3. Parameter verification failed.
1844     * @throws { BusinessError } 15500000 - Inner error.
1845     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1846     * @atomicservice
1847     * @since 12
1848     */
1849    on(type: 'dataChange', keys: Array<string>, callback: Callback<Record<string, ValueType>>): void;
1850
1851    /**
1852     * Unregisters an existing observer.
1853     *
1854     * @param { 'change' } type - Indicates the callback when preferences changes.
1855     * @param { Callback<{ key: string }> } callback - Indicates the callback function.
1856     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1857     *                                                                   2. Incorrect parameter types;
1858     *                                                                   3. Parameter verification failed.
1859     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1860     * @since 9
1861     */
1862    /**
1863     * Unregisters an existing observer.
1864     *
1865     * @param { 'change' } type - Indicates the callback when preferences changes.
1866     * @param { Function } callback - Indicates the callback function.
1867     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1868     *                                                                   2. Incorrect parameter types;
1869     *                                                                   3. Parameter verification failed.
1870     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1871     * @crossplatform
1872     * @since 10
1873     */
1874    /**
1875     * Unregisters an existing observer.
1876     *
1877     * @param { 'change' } type - Indicates the callback when preferences changes.
1878     * @param { Callback<string> } callback - Indicates the callback function.
1879     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1880     *                                                                   2. Incorrect parameter types;
1881     *                                                                   3. Parameter verification failed.
1882     * @throws { BusinessError } 15500000 - Inner error.
1883     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1884     * @crossplatform
1885     * @atomicservice
1886     * @since 11
1887     */
1888    off(type: 'change', callback?: Callback<string>): void;
1889
1890    /**
1891     * Unregisters an existing observer.
1892     *
1893     * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes.
1894     * @param { Function } callback - Indicates the callback function.
1895     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1896     *                                                                   2. Incorrect parameter types;
1897     *                                                                   3. Parameter verification failed.
1898     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1899     * @since 10
1900     */
1901    /**
1902     * Unregisters an existing observer.
1903     *
1904     * @param { 'multiProcessChange' } type - Indicates the callback when preferences changed in multiple processes.
1905     * @param { Callback<string> } callback - Indicates the callback function.
1906     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1907     *                                                                   2. Incorrect parameter types;
1908     *                                                                   3. Parameter verification failed.
1909     * @throws { BusinessError } 15500000 - Inner error.
1910     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1911     * @atomicservice
1912     * @since 11
1913     */
1914    off(type: 'multiProcessChange', callback?: Callback<string>): void;
1915
1916    /**
1917     * Unregisters an observer for changes to the {@ link Preferences} object.
1918     *
1919     * @param { 'dataChange' } type - Indicates the event type.
1920     * @param { Array<string> } keys - Indicates the data whose changes are not observed.
1921     * @param { Callback<Record<string, ValueType>> } callback - Indicates the callback to unregister.
1922     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
1923     *                                                                   2. Incorrect parameter types;
1924     *                                                                   3. Parameter verification failed.
1925     * @throws { BusinessError } 15500000 - Inner error.
1926     * @syscap SystemCapability.DistributedDataManager.Preferences.Core
1927     * @atomicservice
1928     * @since 12
1929     */
1930    off(type: 'dataChange', keys: Array<string>, callback?: Callback<Record<string, ValueType>>): void;
1931  }
1932}
1933
1934export default preferences;
1935