1# Data
2
3
4## Overview
5
6Data (distributed data manager) supports persistence of various structured data on a single device, and data sync and sharing between a device and the cloud. It defines a series of data types for operations, such as data addition, deletion, modification, and query.
7
8**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
9
10**Since**: 11
11
12
13## Summary
14
15
16### File
17
18| Name| Description|
19| -------- | -------- |
20| [data_asset.h](data__asset_8h.md) | Defines data asset structures.<br>File to include: <database/data/data_asset.h><br>Library: libnative_rdb_ndk.z.so<br>|
21
22
23### Types
24
25| Name| Description|
26| -------- | -------- |
27| [Data_AssetStatus](#data_assetstatus) | Defines an enum for data asset statuses.|
28| [Data_Asset](#data_asset) | Defines a struct for a data asset.|
29
30
31### Enums
32
33| Name| Description|
34| -------- | -------- |
35| [Data_AssetStatus](#data_assetstatus) {<br>ASSET_NULL = 0, ASSET_NORMAL, ASSET_INSERT, ASSET_UPDATE,<br>ASSET_DELETE, ASSET_ABNORMAL, ASSET_DOWNLOADING<br>} | Enumerates the data asset statuses.|
36
37
38### Functions
39
40| Name| Description|
41| -------- | -------- |
42| [OH_Data_Asset_SetName](#oh_data_asset_setname) ([Data_Asset](#data_asset) \*asset, const char \*name) | Sets the name of a data asset.|
43| [OH_Data_Asset_SetUri](#oh_data_asset_seturi) ([Data_Asset](#data_asset) \*asset, const char \*uri) | Sets the absolute path (URI) of a data asset in the system.|
44| [OH_Data_Asset_SetPath](#oh_data_asset_setpath) ([Data_Asset](#data_asset) \*asset, const char \*path) | Sets the relative path of a data asset in the application sandbox directory.|
45| [OH_Data_Asset_SetCreateTime](#oh_data_asset_setcreatetime) ([Data_Asset](#data_asset) \*asset, int64_t createTime) | Sets the creation time for a data asset.|
46| [OH_Data_Asset_SetModifyTime](#oh_data_asset_setmodifytime) ([Data_Asset](#data_asset) \*asset, int64_t modifyTime) | Sets the last modification time for a data asset.|
47| [OH_Data_Asset_SetSize](#oh_data_asset_setsize) ([Data_Asset](#data_asset) \*asset, size_t size) | Sets the size of a data asset.|
48| [OH_Data_Asset_SetStatus](#oh_data_asset_setstatus) ([Data_Asset](#data_asset) \*asset, [Data_AssetStatus](#data_assetstatus) status) | Sets the status of a data asset.|
49| [OH_Data_Asset_GetName](#oh_data_asset_getname) ([Data_Asset](#data_asset) \*asset, char \*name, size_t \*length) | Obtains the name of a data asset.|
50| [OH_Data_Asset_GetUri](#oh_data_asset_geturi) ([Data_Asset](#data_asset) \*asset, char \*uri, size_t \*length) | Obtains the absolute path of a data asset.|
51| [OH_Data_Asset_GetPath](#oh_data_asset_getpath) ([Data_Asset](#data_asset) \*asset, char \*path, size_t \*length) | Obtains the relative path of a data asset.|
52| [OH_Data_Asset_GetCreateTime](#oh_data_asset_getcreatetime) ([Data_Asset](#data_asset) \*asset, int64_t \*createTime) | Obtains the creation time of a data asset.|
53| [OH_Data_Asset_GetModifyTime](#oh_data_asset_getmodifytime) ([Data_Asset](#data_asset) \*asset, int64_t \*modifyTime) | Obtains the last modification time of a data asset.|
54| [OH_Data_Asset_GetSize](#oh_data_asset_getsize) ([Data_Asset](#data_asset) \*asset, size_t \*size) | Obtains the space occupied by a data asset.|
55| [OH_Data_Asset_GetStatus](#oh_data_asset_getstatus) ([Data_Asset](#data_asset) \*asset, [Data_AssetStatus](#data_assetstatus) \*status) | Obtains the status of a data asset.|
56| [OH_Data_Asset_CreateOne](#oh_data_asset_createone) () | Creates a [Data_Asset](#data_asset) instance.|
57| [OH_Data_Asset_DestroyOne](#oh_data_asset_destroyone) ([Data_Asset](#data_asset) \*asset) | Destroys a [Data_Asset](#data_asset) instance.|
58| [OH_Data_Asset_CreateMultiple](#oh_data_asset_createmultiple) (uint32_t count) | Creates multiple [Data_Asset](#data_asset) instances.|
59| [OH_Data_Asset_DestroyMultiple](#oh_data_asset_destroymultiple) ([Data_Asset](#data_asset) \*\*assets, uint32_t count) | Destroys multiple [Data_Asset](#data_asset) instances.|
60
61
62## Type Description
63
64
65### Data_Asset
66
67```
68typedef struct Data_Asset Data_Asset
69```
70
71**Description**
72
73Defines a struct for a data asset.
74
75It provides information about a data asset.
76
77**Since**: 11
78
79
80## Enum Description
81
82
83### Data_AssetStatus
84
85```
86enum Data_AssetStatus
87```
88
89**Description**
90
91Enumerates the data asset statuses.
92
93| Value| Description|
94| -------- | -------- |
95| ASSET_NULL | The data asset is null.|
96| ASSET_NORMAL | The data asset is in normal status.|
97| ASSET_INSERT | The data asset is to be inserted to the cloud.|
98| ASSET_UPDATE | The data asset is to be updated to the cloud.|
99| ASSET_DELETE | The data asset is to be deleted from the cloud.|
100| ASSET_ABNORMAL | The data asset is in abnormal status.|
101| ASSET_DOWNLOADING | The data asset is being downloaded to a local device.|
102
103
104## Function Description
105
106
107### OH_Data_Asset_CreateMultiple()
108
109```
110Data_Asset** OH_Data_Asset_CreateMultiple (uint32_t count)
111```
112
113**Description**
114
115Creates multiple [Data_Asset](#data_asset) instances.
116
117**Since**: 11
118
119**Parameters**
120
121| Name| Description|
122| -------- | -------- |
123| count | Number of data assets to create.|
124
125**Returns**
126
127Returns the pointer to the [Data_Asset](#data_asset) instance created if the operation is successful; returns null otherwise.
128
129**See**
130
131[Data_Asset](#data_asset).
132
133
134### OH_Data_Asset_CreateOne()
135
136```
137Data_Asset* OH_Data_Asset_CreateOne ()
138```
139
140**Description**
141
142Creates a [Data_Asset](#data_asset) instance.
143
144**Since**: 11
145
146**Returns**
147
148Returns the pointer to the [Data_Asset](#data_asset) instance created if the operation is successful; returns null otherwise.
149
150**See**
151
152[Data_Asset](#data_asset).
153
154
155### OH_Data_Asset_DestroyMultiple()
156
157```
158int OH_Data_Asset_DestroyMultiple (Data_Asset ** assets, uint32_t count )
159```
160
161**Description**
162
163Destroys multiple [Data_Asset](#data_asset) instances.
164
165**Since**: 11
166
167**Parameters**
168
169| Name| Description|
170| -------- | -------- |
171| assets | Pointer to the [Data_Asset](#data_asset) instances to destroy.|
172| count | Number of the [Data_Asset](#data_asset) instances to destroy.|
173
174**Returns**
175
176Returns **RDB_OK** if the operation is successful; returns an error code otherwise. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
177
178**See**
179
180[Data_Asset](#data_asset), [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
181
182
183### OH_Data_Asset_DestroyOne()
184
185```
186int OH_Data_Asset_DestroyOne (Data_Asset * asset)
187```
188
189**Description**
190
191Destroys a [Data_Asset](#data_asset) instance.
192
193**Since**: 11
194
195**Parameters**
196
197| Name| Description|
198| -------- | -------- |
199| asset | Pointer to the [Data_Asset](#data_asset) instance to destroy.|
200
201**Returns**
202
203Returns **RDB_OK** if the operation is successful; returns an error code otherwise. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
204
205**See**
206
207[Data_Asset](#data_asset), [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
208
209
210### OH_Data_Asset_GetCreateTime()
211
212```
213int OH_Data_Asset_GetCreateTime (Data_Asset * asset, int64_t * createTime )
214```
215
216**Description**
217
218Obtains the creation time of a data asset.
219
220**Since**: 11
221
222**Parameters**
223
224| Name| Description|
225| -------- | -------- |
226| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
227| createTime | Ponter to the creation time obtained, in int64_t format.|
228
229**Returns**
230
231Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
232
233**See**
234
235[Data_Asset](#data_asset)
236
237
238### OH_Data_Asset_GetModifyTime()
239
240```
241int OH_Data_Asset_GetModifyTime (Data_Asset * asset, int64_t * modifyTime )
242```
243
244**Description**
245
246Obtains the last modification time of a data asset.
247
248**Since**: 11
249
250**Parameters**
251
252| Name| Description|
253| -------- | -------- |
254| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
255| modifyTime | Pointer to the last modification time obtained, in int64_t format.|
256
257**Returns**
258
259Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
260
261**See**
262
263[Data_Asset](#data_asset)
264
265
266### OH_Data_Asset_GetName()
267
268```
269int OH_Data_Asset_GetName (Data_Asset * asset, char * name, size_t * length )
270```
271
272**Description**
273
274Obtains the name of a data asset.
275
276**Since**: 11
277
278**Parameters**
279
280| Name| Description|
281| -------- | -------- |
282| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
283| name | Pointer to the data asset name obtained, in the form of a string.|
284| length | Pointer to the length of the name.|
285
286**Returns**
287
288Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
289
290**See**
291
292[Data_Asset](#data_asset)
293
294
295### OH_Data_Asset_GetPath()
296
297```
298int OH_Data_Asset_GetPath (Data_Asset * asset, char * path, size_t * length )
299```
300
301**Description**
302
303Obtains the relative path of a data asset.
304
305**Since**: 11
306
307**Parameters**
308
309| Name| Description|
310| -------- | -------- |
311| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
312| path | Pointer to the relative path of the data asset obtained, in the form of a string.|
313| length | Pointer to the length of the relative path.|
314
315**Returns**
316
317Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
318
319**See**
320
321[Data_Asset](#data_asset)
322
323
324### OH_Data_Asset_GetSize()
325
326```
327int OH_Data_Asset_GetSize (Data_Asset * asset, size_t * size )
328```
329
330**Description**
331
332Obtains the space occupied by a data asset.
333
334**Since**: 11
335
336**Parameters**
337
338| Name| Description|
339| -------- | -------- |
340| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
341| size | Pointer to the data asset size obtained, in the format of size_t.|
342
343**Returns**
344
345Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
346
347**See**
348
349[Data_Asset](#data_asset)
350
351
352### OH_Data_Asset_GetStatus()
353
354```
355int OH_Data_Asset_GetStatus (Data_Asset * asset, Data_AssetStatus * status )
356```
357
358**Description**
359
360Obtains the status of a data asset.
361
362**Since**: 11
363
364**Parameters**
365
366| Name| Description|
367| -------- | -------- |
368| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
369| status | Pointer to the [Data_AssetStatus](#data_assetstatus) obtained.|
370
371**Returns**
372
373Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
374
375**See**
376
377[Data_Asset](#data_asset)
378
379
380### OH_Data_Asset_GetUri()
381
382```
383int OH_Data_Asset_GetUri (Data_Asset * asset, char * uri, size_t * length )
384```
385
386**Description**
387
388Obtains the absolute path (URI) of a data asset.
389
390**Since**: 11
391
392**Parameters**
393
394| Name| Description|
395| -------- | -------- |
396| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
397| uri | Pointer to the absolute path of the data asset obtained, in the form of a string.|
398| length | Pointer to the length of the URI.|
399
400**Returns**
401
402Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
403
404**See**
405
406[Data_Asset](#data_asset)
407
408
409### OH_Data_Asset_SetCreateTime()
410
411```
412int OH_Data_Asset_SetCreateTime (Data_Asset * asset, int64_t createTime )
413```
414
415**Description**
416
417Sets the creation time for a data asset.
418
419**Since**: 11
420
421**Parameters**
422
423| Name| Description|
424| -------- | -------- |
425| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
426| createTime | Creation time to set.|
427
428**Returns**
429
430Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
431
432**See**
433
434[Data_Asset](#data_asset)
435
436
437### OH_Data_Asset_SetModifyTime()
438
439```
440int OH_Data_Asset_SetModifyTime (Data_Asset * asset, int64_t modifyTime )
441```
442
443**Description**
444
445Sets the last modification time for a data asset.
446
447**Since**: 11
448
449**Parameters**
450
451| Name| Description|
452| -------- | -------- |
453| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
454| modifyTime | Last modification time to set.|
455
456**Returns**
457
458Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
459
460**See**
461
462[Data_Asset](#data_asset)
463
464
465### OH_Data_Asset_SetName()
466
467```
468int OH_Data_Asset_SetName (Data_Asset * asset, const char * name )
469```
470
471**Description**
472
473Sets the name of a data asset.
474
475**Since**: 11
476
477**Parameters**
478
479| Name| Description|
480| -------- | -------- |
481| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
482| name | Pointer to the name to set.|
483
484**Returns**
485
486Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
487
488**See**
489
490[Data_Asset](#data_asset)
491
492
493### OH_Data_Asset_SetPath()
494
495```
496int OH_Data_Asset_SetPath (Data_Asset * asset, const char * path )
497```
498
499**Description**
500
501Sets the relative path of a data asset in the application sandbox directory.
502
503**Since**: 11
504
505**Parameters**
506
507| Name| Description|
508| -------- | -------- |
509| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
510| path | Pointer to the relative path to set.|
511
512**Returns**
513
514Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
515
516**See**
517
518[Data_Asset](#data_asset)
519
520
521### OH_Data_Asset_SetSize()
522
523```
524int OH_Data_Asset_SetSize (Data_Asset * asset, size_t size )
525```
526
527**Description**
528
529Sets the size of a data asset.
530
531**Since**: 11
532
533**Parameters**
534
535| Name| Description|
536| -------- | -------- |
537| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
538| size | Size of the data asset to set.|
539
540**Returns**
541
542Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
543
544**See**
545
546[Data_Asset](#data_asset)
547
548
549### OH_Data_Asset_SetStatus()
550
551```
552int OH_Data_Asset_SetStatus (Data_Asset * asset, Data_AssetStatus status )
553```
554
555**Description**
556
557Sets the status of a data asset.
558
559**Since**: 11
560
561**Parameters**
562
563| Name| Description|
564| -------- | -------- |
565| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
566| status | Status to set. For details, see [Data_AssetStatus](#data_assetstatus).|
567
568**Returns**
569
570Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
571
572**See**
573
574[Data_Asset](#data_asset), [Data_AssetStatus](#data_assetstatus)
575
576
577### OH_Data_Asset_SetUri()
578
579```
580int OH_Data_Asset_SetUri (Data_Asset * asset, const char * uri )
581```
582
583**Description**
584
585Sets the absolute path (URI) of a data asset in the system.
586
587**Since**: 11
588
589**Parameters**
590
591| Name| Description|
592| -------- | -------- |
593| asset | Pointer to the target [Data_Asset](#data_asset) instance.|
594| name | Pointer to the URI to set.|
595
596**Returns**
597
598Returns an error code. For details about the error codes, see [OH_Rdb_ErrCode](_r_d_b.md#oh_rdb_errcode-1).
599
600**See**
601
602[Data_Asset](#data_asset)
603