161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci* Copyright (c) 2021 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci* Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci* you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci* You may obtain a copy of the License at
661847f8eSopenharmony_ci*
761847f8eSopenharmony_ci* http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci*
961847f8eSopenharmony_ci* Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci* distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci* See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci* limitations under the License.
1461847f8eSopenharmony_ci*/
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit ArkData
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport { AsyncCallback, Callback } from './@ohos.base';
2261847f8eSopenharmony_ci
2361847f8eSopenharmony_ci/**
2461847f8eSopenharmony_ci * Provides interfaces to obtain and modify storage data.
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @namespace storage
2761847f8eSopenharmony_ci * @name storage
2861847f8eSopenharmony_ci * @since 6
2961847f8eSopenharmony_ci * @deprecated since 9
3061847f8eSopenharmony_ci * @useinstead ohos.preferences.preferences
3161847f8eSopenharmony_ci * @syscap SystemCapability.DistributedDataManager.Preferences.Core
3261847f8eSopenharmony_ci *
3361847f8eSopenharmony_ci */
3461847f8eSopenharmony_ci
3561847f8eSopenharmony_cideclare namespace storage {
3661847f8eSopenharmony_ci  /**
3761847f8eSopenharmony_ci   * Obtains a {@link Storage} instance matching a specified storage file name.
3861847f8eSopenharmony_ci   *
3961847f8eSopenharmony_ci   * <p>The {@link references} instance loads all data of the storage file and
4061847f8eSopenharmony_ci   * resides in the memory. You can use removeStorageFromCache to remove the instance from the memory.
4161847f8eSopenharmony_ci   *
4261847f8eSopenharmony_ci   * @param path Indicates the path of storage file stored.
4361847f8eSopenharmony_ci   * @returns Returns the {@link Storage} instance matching the specified storage file name.
4461847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
4561847f8eSopenharmony_ci   * @since 6
4661847f8eSopenharmony_ci   * @deprecated since 9
4761847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.getPreferences
4861847f8eSopenharmony_ci   */
4961847f8eSopenharmony_ci  function getStorageSync(path: string): Storage;
5061847f8eSopenharmony_ci
5161847f8eSopenharmony_ci  /**
5261847f8eSopenharmony_ci   * Obtains a {@link Storage} instance matching a specified storage file name.
5361847f8eSopenharmony_ci   *
5461847f8eSopenharmony_ci   * <p>The {@link references} instance loads all data of the storage file and
5561847f8eSopenharmony_ci   * resides in the memory. You can use removeStorageFromCache to remove the instance from the memory.
5661847f8eSopenharmony_ci   *
5761847f8eSopenharmony_ci   * @param path Indicates the path of storage file stored.
5861847f8eSopenharmony_ci   * @returns Returns the {@link Storage} instance matching the specified storage file name.
5961847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
6061847f8eSopenharmony_ci   * @since 6
6161847f8eSopenharmony_ci   * @deprecated since 9
6261847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.getPreferences
6361847f8eSopenharmony_ci   */
6461847f8eSopenharmony_ci  function getStorage(path: string, callback: AsyncCallback<Storage>): void;
6561847f8eSopenharmony_ci
6661847f8eSopenharmony_ci  /**
6761847f8eSopenharmony_ci   * Obtains a {@link Storage} instance matching a specified storage file name.
6861847f8eSopenharmony_ci   *
6961847f8eSopenharmony_ci   * <p>The {@link references} instance loads all data of the storage file and
7061847f8eSopenharmony_ci   * resides in the memory. You can use removeStorageFromCache to remove the instance from the memory.
7161847f8eSopenharmony_ci   *
7261847f8eSopenharmony_ci   * @param path Indicates the path of storage file stored.
7361847f8eSopenharmony_ci   * @returns Returns the {@link Storage} instance matching the specified storage file name.
7461847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
7561847f8eSopenharmony_ci   * @since 6
7661847f8eSopenharmony_ci   * @deprecated since 9
7761847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.getPreferences
7861847f8eSopenharmony_ci   */
7961847f8eSopenharmony_ci  function getStorage(path: string): Promise<Storage>;
8061847f8eSopenharmony_ci
8161847f8eSopenharmony_ci  /**
8261847f8eSopenharmony_ci   * Deletes a {@link Storage} instance matching a specified storage file name
8361847f8eSopenharmony_ci   * from the cache which is performed by removeStorageFromCache and deletes the
8461847f8eSopenharmony_ci   * storage file.
8561847f8eSopenharmony_ci   *
8661847f8eSopenharmony_ci   * <p>When deleting the {@link Storage} instance, you must release all references
8761847f8eSopenharmony_ci   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
8861847f8eSopenharmony_ci   * will occur.
8961847f8eSopenharmony_ci   *
9061847f8eSopenharmony_ci   * @param path Indicates the path of storage file
9161847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
9261847f8eSopenharmony_ci   * @since 6
9361847f8eSopenharmony_ci   * @deprecated since 9
9461847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.deletePreferences
9561847f8eSopenharmony_ci   */
9661847f8eSopenharmony_ci  function deleteStorageSync(path: string): void;
9761847f8eSopenharmony_ci
9861847f8eSopenharmony_ci  /**
9961847f8eSopenharmony_ci   * Deletes a {@link Storage} instance matching a specified storage file name
10061847f8eSopenharmony_ci   * from the cache which is performed by removeStorageFromCache and deletes the
10161847f8eSopenharmony_ci   * storage file.
10261847f8eSopenharmony_ci   *
10361847f8eSopenharmony_ci   * <p>When deleting the {@link Storage} instance, you must release all references
10461847f8eSopenharmony_ci   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
10561847f8eSopenharmony_ci   * will occur.
10661847f8eSopenharmony_ci   *
10761847f8eSopenharmony_ci   * @param path Indicates the path of storage file
10861847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
10961847f8eSopenharmony_ci   * @since 6
11061847f8eSopenharmony_ci   * @deprecated since 9
11161847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.deletePreferences
11261847f8eSopenharmony_ci   */
11361847f8eSopenharmony_ci  function deleteStorage(path: string, callback: AsyncCallback<void>): void;
11461847f8eSopenharmony_ci
11561847f8eSopenharmony_ci  /**
11661847f8eSopenharmony_ci   * Deletes a {@link Storage} instance matching a specified storage file name
11761847f8eSopenharmony_ci   * from the cache which is performed by removeStorageFromCache and deletes the
11861847f8eSopenharmony_ci   * storage file.
11961847f8eSopenharmony_ci   *
12061847f8eSopenharmony_ci   * <p>When deleting the {@link Storage} instance, you must release all references
12161847f8eSopenharmony_ci   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
12261847f8eSopenharmony_ci   * will occur.
12361847f8eSopenharmony_ci   *
12461847f8eSopenharmony_ci   * @param path Indicates the path of storage file
12561847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
12661847f8eSopenharmony_ci   * @since 6
12761847f8eSopenharmony_ci   * @deprecated since 9
12861847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.deletePreferences
12961847f8eSopenharmony_ci   */
13061847f8eSopenharmony_ci  function deleteStorage(path: string): Promise<void>;
13161847f8eSopenharmony_ci
13261847f8eSopenharmony_ci  /**
13361847f8eSopenharmony_ci   * Deletes a {@link Storage} instance matching a specified storage file name
13461847f8eSopenharmony_ci   * from the cache.
13561847f8eSopenharmony_ci   *
13661847f8eSopenharmony_ci   * <p>When deleting the {@link Storage} instance, you must release all references
13761847f8eSopenharmony_ci   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
13861847f8eSopenharmony_ci   * will occur.
13961847f8eSopenharmony_ci   *
14061847f8eSopenharmony_ci   * @param path Indicates the path of storage file.
14161847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
14261847f8eSopenharmony_ci   * @since 6
14361847f8eSopenharmony_ci   * @deprecated since 9
14461847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.removePreferencesFromCache
14561847f8eSopenharmony_ci   */
14661847f8eSopenharmony_ci  function removeStorageFromCacheSync(path: string): void;
14761847f8eSopenharmony_ci
14861847f8eSopenharmony_ci  /**
14961847f8eSopenharmony_ci   * Deletes a {@link Storage} instance matching a specified storage file name
15061847f8eSopenharmony_ci   * from the cache.
15161847f8eSopenharmony_ci   *
15261847f8eSopenharmony_ci   * <p>When deleting the {@link Storage} instance, you must release all references
15361847f8eSopenharmony_ci   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
15461847f8eSopenharmony_ci   * will occur.
15561847f8eSopenharmony_ci   *
15661847f8eSopenharmony_ci   * @param path Indicates the path of storage file.
15761847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
15861847f8eSopenharmony_ci   * @since 6
15961847f8eSopenharmony_ci   * @deprecated since 9
16061847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.removePreferencesFromCache
16161847f8eSopenharmony_ci   */
16261847f8eSopenharmony_ci  function removeStorageFromCache(path: string, callback: AsyncCallback<void>): void;
16361847f8eSopenharmony_ci
16461847f8eSopenharmony_ci  /**
16561847f8eSopenharmony_ci   * Deletes a {@link Storage} instance matching a specified storage file name
16661847f8eSopenharmony_ci   * from the cache.
16761847f8eSopenharmony_ci   *
16861847f8eSopenharmony_ci   * <p>When deleting the {@link Storage} instance, you must release all references
16961847f8eSopenharmony_ci   * of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
17061847f8eSopenharmony_ci   * will occur.
17161847f8eSopenharmony_ci   *
17261847f8eSopenharmony_ci   * @param path Indicates the path of storage file.
17361847f8eSopenharmony_ci   * @throws BusinessError if invoked failed
17461847f8eSopenharmony_ci   * @since 6
17561847f8eSopenharmony_ci   * @deprecated since 9
17661847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences.removePreferencesFromCache
17761847f8eSopenharmony_ci   */
17861847f8eSopenharmony_ci  function removeStorageFromCache(path: string): Promise<void>;
17961847f8eSopenharmony_ci
18061847f8eSopenharmony_ci  /**
18161847f8eSopenharmony_ci   * Provides interfaces to obtain and modify storage data.
18261847f8eSopenharmony_ci   *
18361847f8eSopenharmony_ci   * <p>The storage data is stored in a file, which matches only one {@link Storage} instance in the memory.
18461847f8eSopenharmony_ci   * You can use getStorage to obtain the {@link Storage} instance matching
18561847f8eSopenharmony_ci   * the file that stores storage data, and use removeStorageFromCache
18661847f8eSopenharmony_ci   * to remove the {@link Storage} instance from the memory.
18761847f8eSopenharmony_ci   *
18861847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
18961847f8eSopenharmony_ci   *
19061847f8eSopenharmony_ci   * @since 6
19161847f8eSopenharmony_ci   * @deprecated since 9
19261847f8eSopenharmony_ci   * @useinstead ohos.preferences.preferences
19361847f8eSopenharmony_ci   */
19461847f8eSopenharmony_ci  interface Storage {
19561847f8eSopenharmony_ci    /**
19661847f8eSopenharmony_ci    * Obtains the value of a storage in the int format.
19761847f8eSopenharmony_ci    *
19861847f8eSopenharmony_ci    * <p>If the value is {@code null} or not in the int format, the default value is returned.
19961847f8eSopenharmony_ci    *
20061847f8eSopenharmony_ci    * @param key Indicates the key of the storage. It cannot be {@code null} or empty.
20161847f8eSopenharmony_ci    * @param defValue Indicates the default value to return.
20261847f8eSopenharmony_ci    * @returns Returns the value matching the specified key if it is found; returns the default value otherwise.
20361847f8eSopenharmony_ci    * @throws BusinessError if invoked failed
20461847f8eSopenharmony_ci    * @since 6
20561847f8eSopenharmony_ci    * @deprecated since 9
20661847f8eSopenharmony_ci    * @useinstead ohos.preferences.preferences.get
20761847f8eSopenharmony_ci    */
20861847f8eSopenharmony_ci    getSync(key: string, defValue: ValueType): ValueType;
20961847f8eSopenharmony_ci
21061847f8eSopenharmony_ci    /**
21161847f8eSopenharmony_ci    * Obtains the value of a storage in the int format.
21261847f8eSopenharmony_ci    *
21361847f8eSopenharmony_ci    * <p>If the value is {@code null} or not in the int format, the default value is returned.
21461847f8eSopenharmony_ci    *
21561847f8eSopenharmony_ci    * @param key Indicates the key of the storage. It cannot be {@code null} or empty.
21661847f8eSopenharmony_ci    * @param defValue Indicates the default value to return.
21761847f8eSopenharmony_ci    * @returns Returns the value matching the specified key if it is found; returns the default value otherwise.
21861847f8eSopenharmony_ci    * @throws BusinessError if invoked failed
21961847f8eSopenharmony_ci    * @since 6
22061847f8eSopenharmony_ci    * @deprecated since 9
22161847f8eSopenharmony_ci    * @useinstead ohos.preferences.preferences.get
22261847f8eSopenharmony_ci    */
22361847f8eSopenharmony_ci    get(key: string, defValue: ValueType, callback: AsyncCallback<ValueType>): void;
22461847f8eSopenharmony_ci
22561847f8eSopenharmony_ci    /**
22661847f8eSopenharmony_ci    * Obtains the value of a storage in the int format.
22761847f8eSopenharmony_ci    *
22861847f8eSopenharmony_ci    * <p>If the value is {@code null} or not in the int format, the default value is returned.
22961847f8eSopenharmony_ci    *
23061847f8eSopenharmony_ci    * @param key Indicates the key of the storage. It cannot be {@code null} or empty.
23161847f8eSopenharmony_ci    * @param defValue Indicates the default value to return.
23261847f8eSopenharmony_ci    * @returns Returns the value matching the specified key if it is found; returns the default value otherwise.
23361847f8eSopenharmony_ci    * @throws BusinessError if invoked failed
23461847f8eSopenharmony_ci    * @since 6
23561847f8eSopenharmony_ci    * @deprecated since 9
23661847f8eSopenharmony_ci    * @useinstead ohos.preferences.preferences.get
23761847f8eSopenharmony_ci    */
23861847f8eSopenharmony_ci    get(key: string, defValue: ValueType): Promise<ValueType>;
23961847f8eSopenharmony_ci
24061847f8eSopenharmony_ci    /**
24161847f8eSopenharmony_ci     * Checks whether the {@link Storage} object contains a storage matching a specified key.
24261847f8eSopenharmony_ci     *
24361847f8eSopenharmony_ci     * @param key Indicates the key of the storage to check for.
24461847f8eSopenharmony_ci     * @returns Returns {@code true} if the {@link Storage} object contains a storage with the specified key;
24561847f8eSopenharmony_ci     * returns {@code false} otherwise.
24661847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
24761847f8eSopenharmony_ci     * @since 6
24861847f8eSopenharmony_ci     * @deprecated since 9
24961847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.has
25061847f8eSopenharmony_ci     */
25161847f8eSopenharmony_ci    hasSync(key: string): boolean;
25261847f8eSopenharmony_ci
25361847f8eSopenharmony_ci    /**
25461847f8eSopenharmony_ci     * Checks whether the {@link Storage} object contains a storage matching a specified key.
25561847f8eSopenharmony_ci     *
25661847f8eSopenharmony_ci     * @param key Indicates the key of the storage to check for.
25761847f8eSopenharmony_ci     * @returns Returns {@code true} if the {@link Storage} object contains a storage with the specified key;
25861847f8eSopenharmony_ci     * returns {@code false} otherwise.
25961847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
26061847f8eSopenharmony_ci     * @since 6
26161847f8eSopenharmony_ci     * @deprecated since 9
26261847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.has
26361847f8eSopenharmony_ci     */
26461847f8eSopenharmony_ci    has(key: string, callback: AsyncCallback<boolean>): boolean;
26561847f8eSopenharmony_ci
26661847f8eSopenharmony_ci    /**
26761847f8eSopenharmony_ci     * Checks whether the {@link Storage} object contains a storage matching a specified key.
26861847f8eSopenharmony_ci     *
26961847f8eSopenharmony_ci     * @param key Indicates the key of the storage to check for.
27061847f8eSopenharmony_ci     * @returns Returns {@code true} if the {@link Storage} object contains a storage with the specified key;
27161847f8eSopenharmony_ci     * returns {@code false} otherwise.
27261847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
27361847f8eSopenharmony_ci     * @since 6
27461847f8eSopenharmony_ci     * @deprecated since 9
27561847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.has
27661847f8eSopenharmony_ci     */
27761847f8eSopenharmony_ci    has(key: string): Promise<boolean>;
27861847f8eSopenharmony_ci
27961847f8eSopenharmony_ci    /**
28061847f8eSopenharmony_ci     * Sets an int value for the key in the {@link Storage} object.
28161847f8eSopenharmony_ci     *
28261847f8eSopenharmony_ci     * <p>You can call the {@link #flush} or {@link #flushSync} method to save the {@link Storage} object to the
28361847f8eSopenharmony_ci     * file.
28461847f8eSopenharmony_ci     *
28561847f8eSopenharmony_ci     * @param key Indicates the key of the storage to modify. It cannot be {@code null} or empty.
28661847f8eSopenharmony_ci     * @param value Indicates the value of the storage.
28761847f8eSopenharmony_ci     * <tt>MAX_KEY_LENGTH</tt>.
28861847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
28961847f8eSopenharmony_ci     * @since 6
29061847f8eSopenharmony_ci     * @deprecated since 9
29161847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.put
29261847f8eSopenharmony_ci     */
29361847f8eSopenharmony_ci    putSync(key: string, value: ValueType): void;
29461847f8eSopenharmony_ci
29561847f8eSopenharmony_ci    /**
29661847f8eSopenharmony_ci     * Sets an int value for the key in the {@link Storage} object.
29761847f8eSopenharmony_ci     *
29861847f8eSopenharmony_ci     * <p>You can call the {@link #flush} or {@link #flushSync} method to save the {@link Storage} object to the
29961847f8eSopenharmony_ci     * file.
30061847f8eSopenharmony_ci     *
30161847f8eSopenharmony_ci     * @param key Indicates the key of the storage to modify. It cannot be {@code null} or empty.
30261847f8eSopenharmony_ci     * @param value Indicates the value of the storage.
30361847f8eSopenharmony_ci     * <tt>MAX_KEY_LENGTH</tt>.
30461847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
30561847f8eSopenharmony_ci     * @since 6
30661847f8eSopenharmony_ci     * @deprecated since 9
30761847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.put
30861847f8eSopenharmony_ci     */
30961847f8eSopenharmony_ci    put(key: string, value: ValueType, callback: AsyncCallback<void>): void;
31061847f8eSopenharmony_ci
31161847f8eSopenharmony_ci    /**
31261847f8eSopenharmony_ci     * Sets an int value for the key in the {@link Storage} object.
31361847f8eSopenharmony_ci     *
31461847f8eSopenharmony_ci     * <p>You can call the {@link #flush} or {@link #flushSync} method to save the {@link Storage} object to the
31561847f8eSopenharmony_ci     * file.
31661847f8eSopenharmony_ci     *
31761847f8eSopenharmony_ci     * @param key Indicates the key of the storage to modify. It cannot be {@code null} or empty.
31861847f8eSopenharmony_ci     * @param value Indicates the value of the storage.
31961847f8eSopenharmony_ci     * <tt>MAX_KEY_LENGTH</tt>.
32061847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
32161847f8eSopenharmony_ci     * @since 6
32261847f8eSopenharmony_ci     * @deprecated since 9
32361847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.put
32461847f8eSopenharmony_ci     */
32561847f8eSopenharmony_ci    put(key: string, value: ValueType): Promise<void>;
32661847f8eSopenharmony_ci
32761847f8eSopenharmony_ci    /**
32861847f8eSopenharmony_ci     * Deletes the storage with a specified key from the {@link Storage} object.
32961847f8eSopenharmony_ci     *
33061847f8eSopenharmony_ci     * <p>You can call the {@link #flush} method to save the {@link Storage} object to the
33161847f8eSopenharmony_ci     * file.
33261847f8eSopenharmony_ci     *
33361847f8eSopenharmony_ci     * @param key Indicates the key of the storage to delete. It cannot be {@code null} or empty.
33461847f8eSopenharmony_ci     * <tt>MAX_KEY_LENGTH</tt>.
33561847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
33661847f8eSopenharmony_ci     * @since 6
33761847f8eSopenharmony_ci     * @deprecated since 9
33861847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.delete
33961847f8eSopenharmony_ci     */
34061847f8eSopenharmony_ci    deleteSync(key: string): void;
34161847f8eSopenharmony_ci
34261847f8eSopenharmony_ci    /**
34361847f8eSopenharmony_ci     * Deletes the storage with a specified key from the {@link Storage} object.
34461847f8eSopenharmony_ci     *
34561847f8eSopenharmony_ci     * <p>You can call the {@link #flush} method to save the {@link Storage} object to the
34661847f8eSopenharmony_ci     * file.
34761847f8eSopenharmony_ci     *
34861847f8eSopenharmony_ci     * @param key Indicates the key of the storage to delete. It cannot be {@code null} or empty.
34961847f8eSopenharmony_ci     * <tt>MAX_KEY_LENGTH</tt>.
35061847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
35161847f8eSopenharmony_ci     * @since 6
35261847f8eSopenharmony_ci     * @deprecated since 9
35361847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.delete
35461847f8eSopenharmony_ci     */
35561847f8eSopenharmony_ci    delete(key: string, callback: AsyncCallback<void>): void;
35661847f8eSopenharmony_ci
35761847f8eSopenharmony_ci    /**
35861847f8eSopenharmony_ci     * Deletes the storage with a specified key from the {@link Storage} object.
35961847f8eSopenharmony_ci     *
36061847f8eSopenharmony_ci     * <p>You can call the {@link #flush} method to save the {@link Storage} object to the
36161847f8eSopenharmony_ci     * file.
36261847f8eSopenharmony_ci     *
36361847f8eSopenharmony_ci     * @param key Indicates the key of the storage to delete. It cannot be {@code null} or empty.
36461847f8eSopenharmony_ci     * <tt>MAX_KEY_LENGTH</tt>.
36561847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
36661847f8eSopenharmony_ci     * @since 6
36761847f8eSopenharmony_ci     * @deprecated since 9
36861847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.delete
36961847f8eSopenharmony_ci     */
37061847f8eSopenharmony_ci    delete(key: string): Promise<void>;
37161847f8eSopenharmony_ci
37261847f8eSopenharmony_ci    /**
37361847f8eSopenharmony_ci     * Clears all storage from the {@link Storage} object.
37461847f8eSopenharmony_ci     *
37561847f8eSopenharmony_ci     * <p>You can call the {@link #flush} method to save the {@link Storage} object to the
37661847f8eSopenharmony_ci     * file.
37761847f8eSopenharmony_ci     *
37861847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
37961847f8eSopenharmony_ci     * @since 6
38061847f8eSopenharmony_ci     * @deprecated since 9
38161847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.clear
38261847f8eSopenharmony_ci     */
38361847f8eSopenharmony_ci    clearSync(): void;
38461847f8eSopenharmony_ci
38561847f8eSopenharmony_ci    /**
38661847f8eSopenharmony_ci     * Clears all storage from the {@link Storage} object.
38761847f8eSopenharmony_ci     *
38861847f8eSopenharmony_ci     * <p>You can call the {@link #flush} method to save the {@link Storage} object to the
38961847f8eSopenharmony_ci     * file.
39061847f8eSopenharmony_ci     *
39161847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
39261847f8eSopenharmony_ci     * @since 6
39361847f8eSopenharmony_ci     * @deprecated since 9
39461847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.clear
39561847f8eSopenharmony_ci     */
39661847f8eSopenharmony_ci    clear(callback: AsyncCallback<void>): void;
39761847f8eSopenharmony_ci
39861847f8eSopenharmony_ci    /**
39961847f8eSopenharmony_ci     * Clears all storage from the {@link Storage} object.
40061847f8eSopenharmony_ci     *
40161847f8eSopenharmony_ci     * <p>You can call the {@link #flush} method to save the {@link Storage} object to the
40261847f8eSopenharmony_ci     * file.
40361847f8eSopenharmony_ci     *
40461847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
40561847f8eSopenharmony_ci     * @since 6
40661847f8eSopenharmony_ci     * @deprecated since 9
40761847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.clear
40861847f8eSopenharmony_ci     */
40961847f8eSopenharmony_ci    clear(): Promise<void>;
41061847f8eSopenharmony_ci
41161847f8eSopenharmony_ci    /**
41261847f8eSopenharmony_ci     * Asynchronously saves the {@link Storage} object to the file.
41361847f8eSopenharmony_ci     *
41461847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
41561847f8eSopenharmony_ci     * @since 6
41661847f8eSopenharmony_ci     * @deprecated since 9
41761847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.flush
41861847f8eSopenharmony_ci     */
41961847f8eSopenharmony_ci    flushSync(): void;
42061847f8eSopenharmony_ci
42161847f8eSopenharmony_ci    /**
42261847f8eSopenharmony_ci     * Asynchronously saves the {@link Storage} object to the file.
42361847f8eSopenharmony_ci     *
42461847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
42561847f8eSopenharmony_ci     * @since 6
42661847f8eSopenharmony_ci     * @deprecated since 9
42761847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.flush
42861847f8eSopenharmony_ci     */
42961847f8eSopenharmony_ci    flush(callback: AsyncCallback<void>): void;
43061847f8eSopenharmony_ci
43161847f8eSopenharmony_ci    /**
43261847f8eSopenharmony_ci     * Asynchronously saves the {@link Storage} object to the file.
43361847f8eSopenharmony_ci     *
43461847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
43561847f8eSopenharmony_ci     * @since 6
43661847f8eSopenharmony_ci     * @deprecated since 9
43761847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.flush
43861847f8eSopenharmony_ci     */
43961847f8eSopenharmony_ci    flush(): Promise<void>;
44061847f8eSopenharmony_ci
44161847f8eSopenharmony_ci    /**
44261847f8eSopenharmony_ci     * Registers an observer to listen for the change of a {@link Storage} object.
44361847f8eSopenharmony_ci     *
44461847f8eSopenharmony_ci     * @param callback Indicates the callback when storage changes.
44561847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
44661847f8eSopenharmony_ci     * @since 6
44761847f8eSopenharmony_ci     * @deprecated since 9
44861847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.on
44961847f8eSopenharmony_ci     */
45061847f8eSopenharmony_ci    on(type: 'change', callback: Callback<StorageObserver>): void;
45161847f8eSopenharmony_ci
45261847f8eSopenharmony_ci    /**
45361847f8eSopenharmony_ci     * Unregister an existing observer.
45461847f8eSopenharmony_ci     *
45561847f8eSopenharmony_ci     * @param callback Indicates the registered callback.
45661847f8eSopenharmony_ci     * @throws BusinessError if invoked failed
45761847f8eSopenharmony_ci     * @since 6
45861847f8eSopenharmony_ci     * @deprecated since 9
45961847f8eSopenharmony_ci     * @useinstead ohos.preferences.preferences.off
46061847f8eSopenharmony_ci     */
46161847f8eSopenharmony_ci    off(type: 'change', callback: Callback<StorageObserver>): void;
46261847f8eSopenharmony_ci  }
46361847f8eSopenharmony_ci
46461847f8eSopenharmony_ci  /**
46561847f8eSopenharmony_ci   * Indicates possible value types
46661847f8eSopenharmony_ci   * 
46761847f8eSopenharmony_ci   * @since 6
46861847f8eSopenharmony_ci   * @deprecated since 9
46961847f8eSopenharmony_ci   */
47061847f8eSopenharmony_ci  type ValueType = number | string | boolean;
47161847f8eSopenharmony_ci
47261847f8eSopenharmony_ci  /**
47361847f8eSopenharmony_ci   * Define the change data information object.
47461847f8eSopenharmony_ci   *
47561847f8eSopenharmony_ci   * @syscap SystemCapability.DistributedDataManager.Preferences.Core
47661847f8eSopenharmony_ci   *
47761847f8eSopenharmony_ci   * @since 6
47861847f8eSopenharmony_ci   * @deprecated since 9
47961847f8eSopenharmony_ci   */
48061847f8eSopenharmony_ci  interface StorageObserver {
48161847f8eSopenharmony_ci    /**
48261847f8eSopenharmony_ci     * Indicates which key changes
48361847f8eSopenharmony_ci     * 
48461847f8eSopenharmony_ci     * @since 6
48561847f8eSopenharmony_ci     * @deprecated since 9
48661847f8eSopenharmony_ci     */
48761847f8eSopenharmony_ci    key: string;
48861847f8eSopenharmony_ci  }
48961847f8eSopenharmony_ci
49061847f8eSopenharmony_ci  /**
49161847f8eSopenharmony_ci   * Indicates the maximum length of a key (80 characters).
49261847f8eSopenharmony_ci   * 
49361847f8eSopenharmony_ci   * @since 6
49461847f8eSopenharmony_ci   * @deprecated since 9
49561847f8eSopenharmony_ci   */
49661847f8eSopenharmony_ci  const MAX_KEY_LENGTH: 80;
49761847f8eSopenharmony_ci
49861847f8eSopenharmony_ci  /**
49961847f8eSopenharmony_ci   * Indicates the maximum length of a string (8192 characters).
50061847f8eSopenharmony_ci   * 
50161847f8eSopenharmony_ci   * @since 6
50261847f8eSopenharmony_ci   * @deprecated since 9
50361847f8eSopenharmony_ci   */
50461847f8eSopenharmony_ci  const MAX_VALUE_LENGTH: 8192;
50561847f8eSopenharmony_ci}
50661847f8eSopenharmony_ci
50761847f8eSopenharmony_ci/**
50861847f8eSopenharmony_ci * Provides interfaces to obtain and modify storage data.
50961847f8eSopenharmony_ci * @since 6
51061847f8eSopenharmony_ci * @deprecated since 9
51161847f8eSopenharmony_ci * @syscap SystemCapability.DistributedDataManager.Preferences.Core
51261847f8eSopenharmony_ci */
51361847f8eSopenharmony_ciexport default storage;
514