• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @typedef GetStorageOptions
18 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
19 * @FAModelOnly
20 * @since 3
21 * @deprecated since 6
22 */
23export interface GetStorageOptions {
24  /**
25   * Content index.
26   * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
27   *
28   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
29   * @FAModelOnly
30   * @since 3
31   * @deprecated since 6
32   */
33  key: string;
34
35  /**
36   * Default value returned when the key does not exist.
37   * If this parameter is not specified, an empty string is returned.
38   *
39   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
40   * @FAModelOnly
41   * @since 3
42   * @deprecated since 6
43   */
44  default?: string;
45
46  /**
47   * Called when the stored content is read successfully.
48   *
49   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
50   * @FAModelOnly
51   * @since 3
52   * @deprecated since 6
53   */
54  success?: (data: any) => void;
55
56  /**
57   * Called when the stored content fails to be read.
58   *
59   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
60   * @FAModelOnly
61   * @since 3
62   * @deprecated since 6
63   */
64  fail?: (data: string, code: number) => void;
65
66  /**
67   * Called when the execution is completed.
68   *
69   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
70   * @FAModelOnly
71   * @since 3
72   * @deprecated since 6
73   */
74  complete?: () => void;
75}
76
77/**
78 * @typedef SetStorageOptions
79 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
80 * @FAModelOnly
81 * @since 3
82 * @deprecated since 6
83 */
84export interface SetStorageOptions {
85  /**
86   * Index of the stored content to be modified.
87   * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
88   *
89   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
90   * @FAModelOnly
91   * @since 3
92   * @deprecated since 6
93   */
94  key: string;
95
96  /**
97   * Target storage content.
98   *
99   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
100   * @FAModelOnly
101   * @since 3
102   * @deprecated since 6
103   */
104  value: string;
105
106  /**
107   * Called when the stored content is modified successfully.
108   *
109   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
110   * @FAModelOnly
111   * @since 3
112   * @deprecated since 6
113   */
114  success?: () => void;
115
116  /**
117   * Called when the stored content fails to be modified.
118   *
119   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
120   * @FAModelOnly
121   * @since 3
122   * @deprecated since 6
123   */
124  fail?: (data: string, code: number) => void;
125
126  /**
127   * Called when the execution is completed.
128   *
129   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
130   * @FAModelOnly
131   * @since 3
132   * @deprecated since 6
133   */
134  complete?: () => void;
135}
136
137/**
138 * @typedef ClearStorageOptions
139 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
140 * @FAModelOnly
141 * @since 3
142 * @deprecated since 6
143 */
144export interface ClearStorageOptions {
145  /**
146   * Called when the stored content is cleared successfully.
147   *
148   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
149   * @FAModelOnly
150   * @since 3
151   * @deprecated since 6
152   */
153  success?: () => void;
154
155  /**
156   * Called when the stored content fails to be cleared.
157   *
158   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
159   * @FAModelOnly
160   * @since 3
161   * @deprecated since 6
162   */
163  fail?: (data: string, code: number) => void;
164
165  /**
166   * Called when the execution is completed.
167   *
168   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
169   * @FAModelOnly
170   * @since 3
171   * @deprecated since 6
172   */
173  complete?: () => void;
174}
175
176/**
177 * @typedef DeleteStorageOptions
178 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
179 * @FAModelOnly
180 * @since 3
181 * @deprecated since 6
182 */
183export interface DeleteStorageOptions {
184  /**
185   * Content index.
186   * the value contains a maximum of 32 characters and cannot contain special characters such as \/"*+,:;<=>?[]|\x7F.
187   *
188   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
189   * @FAModelOnly
190   * @since 3
191   * @deprecated since 6
192   */
193  key: string;
194
195  /**
196   * Called when the stored content is deleted successfully.
197   *
198   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
199   * @FAModelOnly
200   * @since 3
201   * @deprecated since 6
202   */
203  success?: () => void;
204
205  /**
206   * Called when the stored content fails to be deleted.
207   *
208   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
209   * @FAModelOnly
210   * @since 3
211   * @deprecated since 6
212   */
213  fail?: (data: string, code: number) => void;
214
215  /**
216   * Called when the execution is completed.
217   *
218   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
219   * @FAModelOnly
220   * @since 3
221   * @deprecated since 6
222   */
223  complete?: () => void;
224}
225
226/**
227 * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
228 * @FAModelOnly
229 * @since 3
230 * @deprecated since 6
231 */
232export default class Storage {
233  /**
234   * Reads the stored content.
235   *
236   * @param { GetStorageOptions } options - Indicates the target options.
237   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
238   * @FAModelOnly
239   * @since 3
240   * @deprecated since 6
241   * @useinstead ohos.preferences.preferences.get
242   */
243  static get(options: GetStorageOptions): void;
244
245  /**
246   * Modifies the stored content.
247   *
248   * @param { SetStorageOptions } options - Indicates the target options.
249   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
250   * @FAModelOnly
251   * @since 3
252   * @deprecated since 6
253   */
254  static set(options: SetStorageOptions): void;
255
256  /**
257   * Clears the stored content.
258   *
259   * @param { ClearStorageOptions } options - Indicates the target options.
260   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
261   * @FAModelOnly
262   * @since 3
263   * @deprecated since 6
264   * @useinstead ohos.preferences.preferences.clear
265   */
266  static clear(options?: ClearStorageOptions): void;
267
268  /**
269   * Deletes the stored content.
270   *
271   * @param { DeleteStorageOptions } options - Indicates the target options.
272   * @syscap SystemCapability.DistributedDataManager.Preferences.Core.Lite
273   * @FAModelOnly
274   * @since 3
275   * @deprecated since 6
276   * @useinstead ohos.preferences.preferences.delete
277   */
278  static delete(options: DeleteStorageOptions): void;
279}
280