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