/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file * @kit ArkData */ import { AsyncCallback, Callback } from './@ohos.base'; /** * Provides interfaces to obtain and modify storage data. * * @name storage * @since 6 * @deprecated since 9 * @useinstead ohos.preferences.preferences * @syscap SystemCapability.DistributedDataManager.Preferences.Core * */ declare namespace storage { /** * Obtains a {@link Storage} instance matching a specified storage file name. * *
The {@link references} instance loads all data of the storage file and
* resides in the memory. You can use removeStorageFromCache to remove the instance from the memory.
*
* @param path Indicates the path of storage file stored.
* @returns Returns the {@link Storage} instance matching the specified storage file name.
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.getPreferences
*/
function getStorageSync(path: string): Storage;
function getStorage(path: string, callback: AsyncCallback When deleting the {@link Storage} instance, you must release all references
* of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
* will occur.
*
* @param path Indicates the path of storage file
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.deletePreferences
*/
function deleteStorageSync(path: string): void;
function deleteStorage(path: string, callback: AsyncCallback When deleting the {@link Storage} instance, you must release all references
* of the instance. In addition, do not use the instance to perform data operations. Otherwise, inconsistent data
* will occur.
*
* @param path Indicates the path of storage file.
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.removePreferencesFromCache
*/
function removeStorageFromCacheSync(path: string): void;
function removeStorageFromCache(path: string, callback: AsyncCallback The storage data is stored in a file, which matches only one {@link Storage} instance in the memory.
* You can use getStorage to obtain the {@link Storage} instance matching
* the file that stores storage data, and use removeStorageFromCache
* to remove the {@link Storage} instance from the memory.
*
* @syscap SystemCapability.DistributedDataManager.Preferences.Core
*
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences
*/
interface Storage {
/**
* Obtains the value of a storage in the int format.
*
* If the value is {@code null} or not in the int format, the default value is returned.
*
* @param key Indicates the key of the storage. It cannot be {@code null} or empty.
* @param defValue Indicates the default value to return.
* @returns Returns the value matching the specified key if it is found; returns the default value otherwise.
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.get
*/
getSync(key: string, defValue: ValueType): ValueType;
get(key: string, defValue: ValueType, callback: AsyncCallback You can call the {@link #flush} or {@link #flushSync} method to save the {@link Storage} object to the
* file.
*
* @param key Indicates the key of the storage to modify. It cannot be {@code null} or empty.
* @param value Indicates the value of the storage.
* MAX_KEY_LENGTH.
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.put
*/
putSync(key: string, value: ValueType): void;
put(key: string, value: ValueType, callback: AsyncCallback You can call the {@link #flush} method to save the {@link Storage} object to the
* file.
*
* @param key Indicates the key of the storage to delete. It cannot be {@code null} or empty.
* MAX_KEY_LENGTH.
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.delete
*/
deleteSync(key: string): void;
delete(key: string, callback: AsyncCallback You can call the {@link #flush} method to save the {@link Storage} object to the
* file.
*
* @throws BusinessError if invoked failed
* @since 6
* @deprecated since 9
* @useinstead ohos.preferences.preferences.clear
*/
clearSync(): void;
clear(callback: AsyncCallback