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 21/** 22 * @typedef GetStorageOptions 23 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 24 * @FAModelOnly 25 * @since 3 26 * @deprecated since 6 27 */ 28export interface GetStorageOptions { 29 /** 30 * Content index. 31 * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. 32 * 33 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 34 * @FAModelOnly 35 * @since 3 36 * @deprecated since 6 37 */ 38 key: string; 39 40 /** 41 * Default value returned when the key does not exist. 42 * If this parameter is not specified, an empty string is returned. 43 * 44 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 45 * @FAModelOnly 46 * @since 3 47 * @deprecated since 6 48 */ 49 default?: string; 50 51 /** 52 * Called when the stored content is read successfully. 53 * 54 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 55 * @FAModelOnly 56 * @since 3 57 * @deprecated since 6 58 */ 59 success?: (data: any) => void; 60 61 /** 62 * Called when the stored content fails to be read. 63 * 64 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 65 * @FAModelOnly 66 * @since 3 67 * @deprecated since 6 68 */ 69 fail?: (data: string, code: number) => void; 70 71 /** 72 * Called when the execution is completed. 73 * 74 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 75 * @FAModelOnly 76 * @since 3 77 * @deprecated since 6 78 */ 79 complete?: () => void; 80} 81 82/** 83 * @typedef SetStorageOptions 84 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 85 * @FAModelOnly 86 * @since 3 87 * @deprecated since 6 88 */ 89export interface SetStorageOptions { 90 /** 91 * Index of the stored content to be modified. 92 * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. 93 * 94 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 95 * @FAModelOnly 96 * @since 3 97 * @deprecated since 6 98 */ 99 key: string; 100 101 /** 102 * Target storage content. 103 * 104 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 105 * @FAModelOnly 106 * @since 3 107 * @deprecated since 6 108 */ 109 value: string; 110 111 /** 112 * Called when the stored content is modified successfully. 113 * 114 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 115 * @FAModelOnly 116 * @since 3 117 * @deprecated since 6 118 */ 119 success?: () => void; 120 121 /** 122 * Called when the stored content fails to be modified. 123 * 124 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 125 * @FAModelOnly 126 * @since 3 127 * @deprecated since 6 128 */ 129 fail?: (data: string, code: number) => void; 130 131 /** 132 * Called when the execution is completed. 133 * 134 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 135 * @FAModelOnly 136 * @since 3 137 * @deprecated since 6 138 */ 139 complete?: () => void; 140} 141 142/** 143 * @typedef ClearStorageOptions 144 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 145 * @FAModelOnly 146 * @since 3 147 * @deprecated since 6 148 */ 149export interface ClearStorageOptions { 150 /** 151 * Called when the stored content is cleared successfully. 152 * 153 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 154 * @FAModelOnly 155 * @since 3 156 * @deprecated since 6 157 */ 158 success?: () => void; 159 160 /** 161 * Called when the stored content fails to be cleared. 162 * 163 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 164 * @FAModelOnly 165 * @since 3 166 * @deprecated since 6 167 */ 168 fail?: (data: string, code: number) => void; 169 170 /** 171 * Called when the execution is completed. 172 * 173 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 174 * @FAModelOnly 175 * @since 3 176 * @deprecated since 6 177 */ 178 complete?: () => void; 179} 180 181/** 182 * @typedef DeleteStorageOptions 183 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 184 * @FAModelOnly 185 * @since 3 186 * @deprecated since 6 187 */ 188export interface DeleteStorageOptions { 189 /** 190 * Content index. 191 * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F. 192 * 193 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 194 * @FAModelOnly 195 * @since 3 196 * @deprecated since 6 197 */ 198 key: string; 199 200 /** 201 * Called when the stored content is deleted successfully. 202 * 203 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 204 * @FAModelOnly 205 * @since 3 206 * @deprecated since 6 207 */ 208 success?: () => void; 209 210 /** 211 * Called when the stored content fails to be deleted. 212 * 213 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 214 * @FAModelOnly 215 * @since 3 216 * @deprecated since 6 217 */ 218 fail?: (data: string, code: number) => void; 219 220 /** 221 * Called when the execution is completed. 222 * 223 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 224 * @FAModelOnly 225 * @since 3 226 * @deprecated since 6 227 */ 228 complete?: () => void; 229} 230 231/** 232 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 233 * @FAModelOnly 234 * @since 3 235 * @deprecated since 6 236 */ 237export default class Storage { 238 /** 239 * Reads the stored content. 240 * 241 * @param { GetStorageOptions } options - Indicates the target options. 242 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 243 * @FAModelOnly 244 * @since 3 245 * @deprecated since 6 246 * @useinstead ohos.preferences.preferences.get 247 */ 248 static get(options: GetStorageOptions): void; 249 250 /** 251 * Modifies the stored content. 252 * 253 * @param { SetStorageOptions } options - Indicates the target options. 254 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 255 * @FAModelOnly 256 * @since 3 257 * @deprecated since 6 258 */ 259 static set(options: SetStorageOptions): void; 260 261 /** 262 * Clears the stored content. 263 * 264 * @param { ClearStorageOptions } options - Indicates the target options. 265 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 266 * @FAModelOnly 267 * @since 3 268 * @deprecated since 6 269 * @useinstead ohos.preferences.preferences.clear 270 */ 271 static clear(options?: ClearStorageOptions): void; 272 273 /** 274 * Deletes the stored content. 275 * 276 * @param { DeleteStorageOptions } options - Indicates the target options. 277 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite 278 * @FAModelOnly 279 * @since 3 280 * @deprecated since 6 281 * @useinstead ohos.preferences.preferences.delete 282 */ 283 static delete(options: DeleteStorageOptions): void; 284} 285