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