• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.cloudData (Cloud Service) (System API)
2
3The **cloudData** module provides APIs for implementing device-cloud synergy and device-cloud sharing and setting the device-cloud sync strategy.
4
5Device-cloud synergy enables sync of the structured data (in RDB stores) between devices and the cloud. The cloud serves as a data hub to implement data backup in the cloud and data consistency between the devices with the same account.
6
7Device-cloud sharing enables data sharing across accounts based on device-cloud synergy. Understanding the following concepts helps you better understand the device-cloud sharing process:
8
9- **sharingResource**: an identifier of the string type generated for each data record shared by an application before device-cloud sync is performed. It uniquely identifies the data record being shared.
10- **Participant**: all participants involved in a share, including the inviter and invitees.
11- **invitationCode**: an invitation code generated by the share server for a share operation. It is generated after a data share is initiated and attached to an invitation pushed to the devices of target invitees. The target invitees then confirm the invitation via this code.
12
13The **cloudData** module provides the following functionalities:
14
15- [Config](#config): provides APIs for setting device-cloud synergy, including enabling and disabling device-cloud sync, clearing data, and notifying data changes.
16- [sharing](#sharing11): provides APIs for device-cloud data sharing, including sharing or unsharing data, exiting a share, changing the privilege on the shared data, querying participants, confirming an invitation, changing the invitation confirmation state, and querying the shared resource.
17
18> **NOTE**
19>
20> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
21>
22> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.data.cloudData (Cloud Service)](js-apis-data-cloudData.md).
23>
24> - Before using this module, ensure that the cloud service is available.
25
26## Modules to Import
27
28```ts
29import { cloudData } from '@kit.ArkData';
30```
31
32## ClearAction
33
34Enumerates the operations for clearing the downloaded cloud data locally.
35
36**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
37
38| Name     | Description                        |
39| --------- | ---------------------------- |
40| CLEAR_CLOUD_INFO | Clear the cloud identifier of the data downloaded from the cloud and retain the data locally.|
41| CLEAR_CLOUD_DATA_AND_INFO |Clear the data downloaded from the cloud, excluding the cloud data that has been modified locally.  |
42
43## ExtraData<sup>11+</sup>
44
45Represents the transparently transmitted data, which contains information required for a data change notification.
46
47**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
48
49| Name     | Type  | Mandatory| Description                                                        |
50| --------- | ------ | ---- | ------------------------------------------------------------ |
51| eventId   | string | Yes  | Event ID. The value **cloud_data_change** indicates cloud data changes.             |
52| extraData | string | Yes | Data to be transmitted transparently. <br/>**extraData** is a JSON string that must contain the **data** field. The **data** field contains information required for a change notification, including the account ID, application name, database name, database type, and database table name. All the fields cannot be empty. |
53
54**Example**
55
56```ts
57// accountId: ID of the cloud account.
58// bundleName: application bundle name.
59// containerName: name of the cloud database.
60// databaseScopes: type of the cloud database.
61// recordTypes: names of the tables in the cloud database.
62
63interface ExtraData {
64  eventId: "cloud_data_change",
65  extraData: '{
66    "data": "{
67     "accountId": "aaa",
68     "bundleName": "com.bbb.xxx",
69     "containerName": "alias",
70     "databaseScopes": ["private", "shared"],
71     "recordTypes": ["xxx", "yyy", "zzz"]
72    }"
73  }'
74}
75
76```
77
78## StatisticInfo<sup>12+</sup>
79
80Represents the device-cloud sync statistics.
81
82**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
83
84| Name     | Type  | Mandatory| Description                                                 |
85| --------- | ------ | ---- |-----------------------------------------------------|
86| table   | string | Yes  | Name of the table queried. For example, the value **cloud_notes** indicates that the sync information of the **cloud_notes** table is queried.|
87| inserted   | number | Yes  | Number of data records that are added locally and have not been synced to the cloud. For example, the value **2** indicates that the table has two data records that are added locally but not synced to the cloud.         |
88| updated   | number | Yes  | Number of data records that are modified locally or on the cloud but have not been synced. For example, the value **2** indicates that the table has two data records that are updated locally or on the cloud but not synced.    |
89| normal | number | Yes  | Number of consistent data records between the device and the cloud. For example, the value **2** indicates that table has two data records that are consistent between the device and the cloud.                    |
90
91## SyncInfo<sup>12+</sup>
92
93Represents information about the last device-cloud sync.
94
95**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
96
97| Name      | Type                                                        | Mandatory| Description                      |
98| ---------- | ------------------------------------------------------------ | ---- | -------------------------- |
99| startTime  | Date                                                         | Yes  | Start time of the last device-cloud sync.|
100| finishTime | Date                                                         | Yes  | End time of the last device-cloud sync.|
101| code       | [relationalStore.ProgressCode](js-apis-data-relationalStore.md#progresscode10) | Yes  | Result of the last device-cloud sync.|
102
103
104## Config
105
106Provides APIs for setting device-cloud synergy, including enabling and disabling device-cloud synergy, clearing data, and notifying data changes.
107
108### enableCloud
109
110static enableCloud(accountId: string, switches: Record<string, boolean>, callback: AsyncCallback&lt;void&gt;): void
111
112Enables device-cloud synergy. This API uses an asynchronous callback to return the result.
113
114**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
115
116**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
117
118**Parameters**
119
120| Name   | Type                           | Mandatory| Description                                                        |
121| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
122| accountId | string                          | Yes  | ID of the cloud account.                                        |
123| switches  | Record<string, boolean>         | Yes  | Device-cloud synergy settings for applications. The value **true** means to enable device-cloud synergy; the value **false** means the opposite. |
124| callback  | AsyncCallback&lt;void&gt;       | Yes  | Callback used to return the result.                                                  |
125
126**Error codes**
127
128For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
129
130| ID| Error Message                                            |
131| -------- | ---------------------------------------------------- |
132| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
133| 202      | Permission verification failed, application which is not a system application uses system API.|
134| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
135| 801      | Capability not supported.|
136
137**Example**
138
139```ts
140import { BusinessError } from '@kit.BasicServicesKit';
141
142let account: string = 'test_id';
143let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
144try {
145  cloudData.Config.enableCloud(account, switches, (err: BusinessError) => {
146    if (err === undefined) {
147      console.info('Succeeded in enabling cloud');
148    } else {
149      console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
150    }
151  });
152} catch (e) {
153  let error = e as BusinessError;
154  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
155}
156```
157
158### enableCloud
159
160static enableCloud(accountId: string, switches: Record<string, boolean>): Promise&lt;void&gt;
161
162Enables device-cloud synergy. This API uses a promise to return the result.
163
164**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
165
166**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
167
168**Parameters**
169
170| Name   | Type                           | Mandatory| Description                                                        |
171| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
172| accountId | string                          | Yes  | ID of the cloud account.                                        |
173| switches  | Record<string, boolean>         | Yes  | Device-cloud synergy settings for applications. The value **true** means to enable device-cloud synergy; the value **false** means the opposite. |
174
175**Return value**
176
177| Type               | Description                     |
178| ------------------- | ------------------------- |
179| Promise&lt;void&gt; | Promise that returns no value.|
180
181**Error codes**
182
183For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
184
185| ID| Error Message                                            |
186| -------- | ---------------------------------------------------- |
187| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
188| 202      | Permission verification failed, application which is not a system application uses system API.|
189| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
190| 801      | Capability not supported.|
191
192**Example**
193
194```ts
195import { BusinessError } from '@kit.BasicServicesKit';
196
197let account: string = 'test_id';
198let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
199try {
200  cloudData.Config.enableCloud(account, switches).then(() => {
201    console.info('Succeeded in enabling cloud');
202  }).catch((err: BusinessError) => {
203    console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
204  });
205} catch (e) {
206  let error = e as BusinessError;
207  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
208}
209```
210
211### disableCloud
212
213static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;): void
214
215Disables device-cloud synergy. This API uses an asynchronous callback to return the result.
216
217**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
218
219**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
220
221**Parameters**
222
223| Name   | Type                     | Mandatory| Description                |
224| --------- | ------------------------- | ---- | -------------------- |
225| accountId | string                    | Yes  | ID of the cloud account.|
226| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
227
228**Error codes**
229
230For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
231
232| ID| Error Message                                            |
233| -------- | ---------------------------------------------------- |
234| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
235| 202      | Permission verification failed, application which is not a system application uses system API.|
236| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
237| 801      | Capability not supported.|
238
239**Example**
240
241```ts
242import { BusinessError } from '@kit.BasicServicesKit';
243
244let account: string = 'test_id';
245try {
246  cloudData.Config.disableCloud(account, (err: BusinessError) => {
247    if (err === undefined) {
248      console.info('Succeeded in disabling cloud');
249    } else {
250      console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
251    }
252  });
253} catch (e) {
254  let error = e as BusinessError;
255  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
256}
257```
258
259### disableCloud
260
261static disableCloud(accountId: string): Promise&lt;void&gt;
262
263Disables device-cloud synergy. This API uses a promise to return the result.
264
265**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
266
267**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
268
269**Parameters**
270
271| Name   | Type  | Mandatory| Description                |
272| --------- | ------ | ---- | -------------------- |
273| accountId | string | Yes  | ID of the cloud account.|
274
275**Return value**
276
277| Type               | Description                     |
278| ------------------- | ------------------------- |
279| Promise&lt;void&gt; | Promise that returns no value.|
280
281**Error codes**
282
283For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
284
285| ID| Error Message                                            |
286| -------- | ---------------------------------------------------- |
287| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
288| 202      | Permission verification failed, application which is not a system application uses system API.|
289| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
290| 801      | Capability not supported.|
291
292**Example**
293
294```ts
295import { BusinessError } from '@kit.BasicServicesKit';
296
297let account: string = 'test_id';
298try {
299  cloudData.Config.disableCloud(account).then(() => {
300    console.info('Succeeded in disabling cloud');
301  }).catch((err: BusinessError) => {
302    console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
303  });
304} catch (e) {
305  let error = e as BusinessError;
306  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
307}
308```
309
310### changeAppCloudSwitch
311
312static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback&lt;void&gt;): void
313
314Changes the device-cloud synergy setting for an application. This API uses an asynchronous callback to return the result.
315
316**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
317
318**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
319
320**Parameters**
321
322| Name   | Type                           | Mandatory| Description                        |
323| --------- | ------------------------------- | ---- | ---------------------------- |
324| accountId | string                          | Yes  | ID of the cloud account.|
325| bundleName| string                         | Yes  | Bundle name of the application.|
326| status    | boolean                        | Yes  | New device-cloud synergy setting. The value **true** means to enable device-cloud synergy; the value **false** means the opposite.|
327| callback  | AsyncCallback&lt;void&gt;       | Yes  | Callback used to return the result.                  |
328
329**Error codes**
330
331For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
332
333| ID| Error Message                                            |
334| -------- | ---------------------------------------------------- |
335| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
336| 202      | Permission verification failed, application which is not a system application uses system API.|
337| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
338| 801      | Capability not supported.|
339
340**Example**
341
342```ts
343import { BusinessError } from '@kit.BasicServicesKit';
344
345let account: string = 'test_id';
346let bundleName: string = 'test_bundleName';
347try {
348  cloudData.Config.changeAppCloudSwitch(account, bundleName, true, (err: BusinessError) => {
349    if (err === undefined) {
350      console.info('Succeeded in changing App cloud switch');
351    } else {
352      console.error(`Failed to change App cloud switch. Code: ${err.code}, message: ${err.message}`);
353    }
354  });
355} catch (e) {
356  let error = e as BusinessError;
357  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
358}
359```
360
361### changeAppCloudSwitch
362
363static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise&lt;void&gt;
364
365Changes the device-cloud synergy setting for an application. This API uses a promise to return the result.
366
367**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
368
369**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
370
371**Parameters**
372
373| Name   | Type                           | Mandatory| Description                        |
374| --------- | ------------------------------- | ---- | ---------------------------- |
375| accountId | string                          | Yes  | ID of the cloud account.|
376| bundleName| string                         | Yes  | Bundle name of the application.|
377| status    | boolean                        | Yes  | New device-cloud synergy setting. The value **true** means to enable device-cloud synergy; the value **false** means the opposite.|
378
379**Return value**
380
381| Type               | Description                     |
382| ------------------- | ------------------------- |
383| Promise&lt;void&gt; | Promise that returns no value.|
384
385**Error codes**
386
387For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
388
389| ID| Error Message                                            |
390| -------- | ---------------------------------------------------- |
391| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
392| 202      | Permission verification failed, application which is not a system application uses system API.|
393| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
394| 801      | Capability not supported.|
395
396**Example**
397
398```ts
399import { BusinessError } from '@kit.BasicServicesKit';
400
401let account: string = 'test_id';
402let bundleName: string = 'test_bundleName';
403try {
404  cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
405    console.info('Succeeded in changing App cloud switch');
406  }).catch((err: BusinessError) => {
407    console.error(`Failed to change App cloud switch. Code is ${err.code}, message is ${err.message}`);
408  });
409} catch (e) {
410  let error = e as BusinessError;
411  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
412}
413```
414
415### notifyDataChange
416
417static notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
418
419Notifies the data changes in the cloud. This API uses an asynchronous callback to return the result.
420
421**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
422
423**System capability**: SystemCapability.DistributedDataManager.CloudSync.Server
424
425**Parameters**
426
427| Name    | Type                     | Mandatory| Description                |
428| ---------- | ------------------------- | ---- | -------------------- |
429| accountId  | string                    | Yes  | ID of the cloud account.|
430| bundleName | string                    | Yes  | Bundle name of the application.            |
431| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.          |
432
433**Error codes**
434
435For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
436
437| ID| Error Message                                            |
438| -------- | ---------------------------------------------------- |
439| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
440| 202      | Permission verification failed, application which is not a system application uses system API.|
441| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
442| 801      | Capability not supported.|
443
444**Example**
445
446```ts
447import { BusinessError } from '@kit.BasicServicesKit';
448
449let account: string = 'test_id';
450let bundleName: string = 'test_bundleName';
451try {
452  cloudData.Config.notifyDataChange(account, bundleName, (err: BusinessError) => {
453    if (err === undefined) {
454      console.info('Succeeded in notifying the change of data');
455    } else {
456      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
457    }
458  });
459} catch (e) {
460  let error = e as BusinessError;
461  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
462}
463```
464
465### notifyDataChange
466
467static notifyDataChange(accountId: string,bundleName: string): Promise&lt;void&gt;
468
469Notifies the data changes in the cloud. This API uses a promise to return the result.
470
471**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
472
473**System capability**: SystemCapability.DistributedDataManager.CloudSync.Server
474
475**Parameters**
476
477| Name    | Type  | Mandatory| Description                |
478| ---------- | ------ | ---- | -------------------- |
479| accountId  | string | Yes  | ID of the cloud account.|
480| bundleName | string | Yes  | Bundle name of the application.            |
481
482**Return value**
483
484| Type               | Description                     |
485| ------------------- | ------------------------- |
486| Promise&lt;void&gt; | Promise that returns no value.|
487
488**Error codes**
489
490For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
491
492| ID| Error Message                                            |
493| -------- | ---------------------------------------------------- |
494| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
495| 202      | Permission verification failed, application which is not a system application uses system API.|
496| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
497| 801      | Capability not supported.|
498
499**Example**
500
501```ts
502import { BusinessError } from '@kit.BasicServicesKit';
503
504let account: string = 'test_id';
505let bundleName: string = 'test_bundleName';
506try {
507  cloudData.Config.notifyDataChange(account, bundleName).then(() => {
508    console.info('Succeeded in notifying the change of data');
509  }).catch((err: BusinessError) => {
510    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
511  });
512} catch (e) {
513  let error = e as BusinessError;
514  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
515}
516```
517
518### notifyDataChange<sup>11+</sup>
519
520 **static** notifyDataChange(extInfo: ExtraData, callback: AsyncCallback&lt;void&gt;):void
521
522Notifies the data changes in the cloud with the specified information, such as the database and table names (specified by the **extraData** field in **extInfo**). This API uses an asynchronous callback to return the result.
523
524**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
525
526**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
527
528**Parameters**
529
530| Name  | Type                     | Mandatory| Description                                   |
531| -------- | ------------------------- | ---- | --------------------------------------- |
532| extInfo  | [ExtraData](#extradata11)   | Yes  | Transparently transmitted data, including information about the application that has data changes.|
533| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
534
535**Error codes**
536
537For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
538
539| ID| Error Message                                            |
540| -------- | ---------------------------------------------------- |
541| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
542| 202      | Permission verification failed, application which is not a system application uses system API.|
543| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
544| 801      | Capability not supported.|
545
546**Example**
547
548```ts
549import { BusinessError } from '@kit.BasicServicesKit';
550
551let eventId: string = "cloud_data_change";
552let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
553try {
554  cloudData.Config.notifyDataChange({
555    eventId: eventId, extraData: extraData
556  }, (err: BusinessError) => {
557    if (err === undefined) {
558      console.info('Succeeded in notifying the change of data');
559    } else {
560      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
561    }
562  });
563} catch (e) {
564  let error = e as BusinessError;
565  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
566}
567```
568
569### notifyDataChange<sup>11+</sup>
570
571static notifyDataChange(extInfo: ExtraData, userId: number,callback: AsyncCallback&lt;void&gt;):void
572
573Notifies the data changes of a user in the cloud. This API uses an asynchronous callback to return the result. You can also specify the database and tables with data changes in the **extraData** field in **extInfo**.
574
575**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
576
577**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
578
579**Parameters**
580
581| Name  | Type                     | Mandatory| Description                                           |
582| -------- | ------------------------- | ---- | ----------------------------------------------- |
583| extInfo  | [ExtraData](#extradata11)   | Yes  | Transparently transmitted data, including information about the application that has data changes.       |
584| userId   | number                    | Yes  | User ID in the system.|
585| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
586
587**Error codes**
588
589For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
590
591| ID| Error Message                                            |
592| -------- | ---------------------------------------------------- |
593| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
594| 202      | Permission verification failed, application which is not a system application uses system API.|
595| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
596| 801      | Capability not supported.|
597
598**Example**
599
600```ts
601import { BusinessError } from '@kit.BasicServicesKit';
602
603let eventId: string = "cloud_data_change";
604let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
605let userId: number = 100;
606try {
607  cloudData.Config.notifyDataChange({
608    eventId: eventId, extraData: extraData
609  }, userId, (err: BusinessError) => {
610    if (err === undefined) {
611      console.info('Succeeded in notifying the change of data');
612    } else {
613      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
614    }
615  });
616} catch (e) {
617  let error = e as BusinessError;
618  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
619}
620```
621
622### notifyDataChange<sup>11+</sup>
623
624**static** notifyDataChange(extInfo: ExtraData, userId?: number): Promise&lt;void&gt;
625
626Notifies the data changes in the cloud. This API uses a promise to return the result. You can specify the database and tables with data changes in the **extraData** field in **extInfo**, and specify the user ID.
627
628**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
629
630**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
631
632**Parameters**
633
634| Name | Type                   | Mandatory| Description                                           |
635| ------- | ----------------------- | ---- | ----------------------------------------------- |
636| extInfo | [ExtraData](#extradata11) | Yes  | Transparently transmitted data, including information about the application that has data changes.        |
637| userId  | number                  | No  | User ID. This parameter is optional. The default value is the current user ID. If this parameter is specified, the value must be an existing user ID in the system.|
638
639**Return value**
640
641| Type               | Description                     |
642| ------------------- | ------------------------- |
643| Promise&lt;void&gt; | Promise that returns no value.|
644
645**Error codes**
646
647For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
648
649| ID| Error Message                                            |
650| -------- | ---------------------------------------------------- |
651| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
652| 202      | Permission verification failed, application which is not a system application uses system API.|
653| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
654| 801      | Capability not supported.|
655
656**Example**
657
658```ts
659import { BusinessError } from '@kit.BasicServicesKit';
660
661let eventId: string = "cloud_data_change";
662let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
663let userId: number = 100;
664try {
665  cloudData.Config.notifyDataChange({
666    eventId: eventId, extraData: extraData
667  }, userId).then(() => {
668    console.info('Succeeded in notifying the change of data');
669  }).catch((err: BusinessError) => {
670    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
671  });
672} catch (e) {
673  let error = e as BusinessError;
674  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
675}
676```
677
678### queryStatistics<sup>12+</sup>
679
680static queryStatistics(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record&lt;string, Array&lt;StatisticInfo&gt;&gt;&gt;
681
682Queries device-cloud data statistics, which include the data not synced, data synced and consistent, and data synced but inconsistent between the device and the cloud. This API uses a promise to return the result.
683
684**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
685
686**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
687
688**Parameters**
689
690| Name | Type     | Mandatory| Description                               |
691| ------- |---------| ---- |-----------------------------------|
692| accountId | string  | Yes  | ID of the cloud account.                      |
693| bundleName | string  | Yes  | Bundle name of the application.                            |
694| storeId  | string  | No  | Name of the RDB store. If this parameter is not specified, all local databases of this application are queried by default.|
695
696**Return value**
697
698| Type                                                                                  | Description                    |
699|--------------------------------------------------------------------------------------| ------------------------ |
700| Promise&lt;Record&lt;string, Array&lt;[StatisticInfo](#statisticinfo12)&gt;&gt;&gt; | Promise used to return the table name and statistics.|
701
702**Error codes**
703
704For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
705
706| ID| Error Message                                            |
707| -------- | ---------------------------------------------------- |
708| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
709| 202      | Permission verification failed, application which is not a system application uses system API.|
710| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
711| 801      | Capability not supported.|
712
713**Example**
714
715```ts
716import { BusinessError } from '@kit.BasicServicesKit';
717
718const accountId:string = "accountId";
719const bundleName:string = "bundleName";
720const storeId:string = "storeId";
721
722cloudData.Config.queryStatistics(accountId, bundleName, storeId).then((result) => {
723    console.info(`Succeeded in querying statistics. Info is ${JSON.stringify(result)}`);
724}).catch((err: BusinessError) => {
725    console.error(`Failed to query statistics. Error code is ${err.code}, message is ${err.message}`);
726});
727```
728
729### queryLastSyncInfo<sup>12+</sup>
730
731static queryLastSyncInfo(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record<string, SyncInfo>>
732
733Queries information about the last device-cloud sync. This API uses a promise to return the result.
734
735**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
736
737**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
738
739**Parameters**
740
741| Name    | Type  | Mandatory| Description                                                        |
742| ---------- | ------ | ---- | ------------------------------------------------------------ |
743| accountId  | string | Yes  | ID of the cloud account.                                        |
744| bundleName | string | Yes  | Bundle name of the application.                                                  |
745| storeId    | string | No  | Name of the RDB store. The default value is an empty string. If the default value is used, this API queries the last device-cloud sync information of all databases of this application.|
746
747**Return value**
748
749| Type                                                        | Description                                        |
750| ------------------------------------------------------------ | -------------------------------------------- |
751| Promise&lt;Record&lt;string, [SyncInfo](#syncinfo12)&gt;&gt; | Promise used to return the database name and the result set of the last device-cloud sync.|
752
753**Error codes**
754
755For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
756
757| ID| Error Message                                            |
758| -------- | ---------------------------------------------------- |
759| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
760| 202      | Permission verification failed, application which is not a system application uses system API.|
761| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
762| 801      | Capability not supported.|
763
764**Example**
765
766```ts
767import { BusinessError } from '@kit.BasicServicesKit';
768
769const accountId:string = "accountId";
770const bundleName:string = "bundleName";
771const storeId:string = "storeId";
772try {
773    cloudData.Config.queryLastSyncInfo(accountId, bundleName, storeId).then((result) => {
774    	console.info(`Succeeded in querying last syncinfo. Info is ${JSON.stringify(result)}`);
775	}).catch((err: BusinessError) => {
776    	console.error(`Failed to query last syncinfo. Error code is ${err.code}, message is ${err.message}`);
777	});
778} catch(e) {
779    let error = e as BusinessError;
780  	console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
781}
782```
783
784### setGlobalCloudStrategy<sup>12+</sup>
785
786static setGlobalCloudStrategy(strategy: StrategyType, param?: Array&lt;commonType.ValueType&gt;): Promise&lt;void&gt;
787
788Sets a global device-cloud sync strategy. This API uses a promise to return the result.
789
790**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
791
792**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
793
794**Parameters**
795
796| Name    | Type                                                                    | Mandatory| Description               |
797| ---------- |------------------------------------------------------------------------| ---- |-------------------|
798| strategy  | [StrategyType](js-apis-data-cloudData.md#strategytype)    | Yes  | Type of the strategy to set.         |
799| param | Array&lt;[commonType.ValueType](js-apis-data-commonType.md#valuetype)&gt; | No  | Strategy parameters to set. If this parameter is not specified, the strategy configuration is deleted by default. |
800
801**Return value**
802
803| Type               | Description                     |
804| ------------------- | ------------------------- |
805| Promise&lt;void&gt; | Promise that returns no value.|
806
807**Error codes**
808
809For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
810
811| ID| Error Message                                            |
812| -------- | ---------------------------------------------------- |
813| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
814| 202      | Permission verification failed, application which is not a system application uses system API.|
815| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
816| 801      | Capability not supported.|
817
818**Example**
819
820```ts
821import { BusinessError } from '@kit.BasicServicesKit';
822
823cloudData.Config.setGlobalCloudStrategy(cloudData.StrategyType.NETWORK, [cloudData.NetWorkStrategy.WIFI]).then(() => {
824    console.info('Succeeded in setting the global cloud strategy');
825}).catch((err: BusinessError) => {
826    console.error(`Failed to set global cloud strategy. Code: ${err.code}, message: ${err.message}`);
827});
828```
829
830###  clear
831
832static clear(accountId: string, appActions: Record<string, ClearAction>,  callback: AsyncCallback&lt;void&gt;): void
833
834Clears the cloud data locally. This API uses an asynchronous callback to return the result.
835
836**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
837
838**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
839
840**Parameters**
841
842| Name    | Type                                               | Mandatory| Description                            |
843| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
844| accountId  | string                                              | Yes  | ID of the cloud account.            |
845| appActions | Record<string, [ClearAction](#clearaction)>         | Yes  | Information about the application whose data is to be cleared and the operation to perform.|
846| callback   | AsyncCallback&lt;void&gt;                           | Yes  | Callback used to return the result.                      |
847
848**Error codes**
849
850For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
851
852| ID| Error Message                                            |
853| -------- | ---------------------------------------------------- |
854| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
855| 202      | Permission verification failed, application which is not a system application uses system API.|
856| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
857| 801      | Capability not supported.|
858
859**Example**
860
861```ts
862import { BusinessError } from '@kit.BasicServicesKit';
863
864let account: string = "test_id";
865type dataType = Record<string, cloudData.ClearAction>
866let appActions: dataType = {
867  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
868  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
869};
870try {
871  cloudData.Config.clear(account, appActions, (err: BusinessError) => {
872    if (err === undefined) {
873      console.info('Succeeding in clearing cloud data');
874    } else {
875      console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
876    }
877  });
878} catch (e) {
879  let error = e as BusinessError;
880  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
881}
882```
883
884### clear
885
886static clear(accountId: string, appActions: Record<string, ClearAction>): Promise&lt;void&gt;
887
888Clears the cloud data locally. This API uses a promise to return the result.
889
890**Required permissions**: ohos.permission.CLOUDDATA_CONFIG
891
892**System capability**: SystemCapability.DistributedDataManager.CloudSync.Config
893
894**Parameters**
895
896| Name    | Type                                               | Mandatory| Description                            |
897| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
898| accountId  | string                                              | Yes  | ID of the cloud account.            |
899| appActions | Record<string, [ClearAction](#clearaction)>         | Yes  | Information about the application whose data is to be cleared and the operation to perform.|
900
901**Return value**
902
903| Type               | Description                     |
904| ------------------- | ------------------------- |
905| Promise&lt;void&gt; | Promise that returns no value.|
906
907**Error codes**
908
909For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
910
911| ID| Error Message                                            |
912| -------- | ---------------------------------------------------- |
913| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
914| 202      | Permission verification failed, application which is not a system application uses system API.|
915| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
916| 801      | Capability not supported.|
917
918**Example**
919
920```ts
921import { BusinessError } from '@kit.BasicServicesKit';
922
923let account: string = "test_id";
924type dataType = Record<string, cloudData.ClearAction>;
925let appActions: dataType = {
926  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
927  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
928};
929try {
930  cloudData.Config.clear(account, appActions).then(() => {
931    console.info('Succeeding in clearing cloud data');
932  }).catch((err: BusinessError) => {
933    console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
934  });
935} catch (e) {
936  let error = e as BusinessError;
937  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
938}
939```
940
941## sharing<sup>11+</sup>
942
943Provides APIs for device-cloud data sharing, including sharing or unsharing data, exiting a share, changing the privilege on the shared data, querying participants, confirming an invitation, changing the invitation confirmation state, and querying the shared resource.
944
945### Role<sup>11+</sup>
946
947Enumerates the roles of the participants in a device-cloud share.
948
949**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
950
951| Name          | Value  | Description                              |
952| --------------| ---- | ---------------------------------- |
953| ROLE_INVITER  | 0    | Inviter, the one who shares data. Use the enum name rather than the enum value.|
954| ROLE_INVITEE  | 1    | Invitee, the one who can use the shared data. Use the enum name rather than the enum value.|
955
956### State<sup>11+</sup>
957
958Enumerates the device-cloud sharing states.
959
960**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
961
962| Name          | Value  | Description                              |
963| --------------| ---- | ---------------------------------- |
964| STATE_UNKNOWN    | 0    | Unknown state. Use the enum name rather than the enum value.  |
965| STATE_ACCEPTED   | 1    | The device-cloud sharing invitation is accepted. Use the enum name rather than the enum value.|
966| STATE_REJECTED   | 2    | The device-cloud sharing invitation is rejected. Use the enum name rather than the enum value.|
967| STATE_SUSPENDED  | 3    | The device-cloud sharing is suspended temporarily. Use the enum name rather than the enum value.|
968| STATE_UNAVAILABLE<sup>12+</sup>   | 4    | The device-cloud sharing is unavailable. Use the enum name rather than the enum value.|
969
970### SharingCode<sup>11+</sup>
971
972Enumerates the error codes for device-cloud sharing.
973
974**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
975
976| Name          | Value  | Description                              |
977| --------------| ---- | ---------------------------------- |
978| SUCCESS                 | 0    | Operation successful. Use the enum name rather than the enum value.  |
979| REPEATED_REQUEST        | 1    | Repeated invitation, which means the participant has been invited. Use the enum name rather than the enum value.|
980| NOT_INVITER             | 2    | The participant is not the inviter of this share. Use the enum name rather than the enum value.|
981| NOT_INVITER_OR_INVITEE  | 3    | Invalid participant, which means the participant is neither the inviter nor the invitee. Use the enum name rather than the enum value.|
982| OVER_QUOTA              | 4    | The number of device-cloud sharing times has reached the limit for the current account. Use the enum name rather than the enum value.  |
983| TOO_MANY_PARTICIPANTS   | 5    | The number of device-cloud sharing participants has reached the limit. Use the enum name rather than the enum value.|
984| INVALID_ARGS            | 6    | Invalid parameter. Use the enum name rather than the enum value.|
985| NETWORK_ERROR           | 7    | Network error. Use the enum name rather than the enum value.|
986| CLOUD_DISABLED          | 8    | Cloud is disabled. Use the enum name rather than the enum value.  |
987| SERVER_ERROR            | 9    | Server error. Use the enum name rather than the enum value.|
988| INNER_ERROR             | 10   | System internal error. Use the enum name rather than the enum value.|
989| INVALID_INVITATION      | 11   | Invalid invitation, which means the current invitation has expired or does not exist. Use the enum name rather than the enum value.|
990| RATE_LIMIT              | 12   | The amount of data to be synced at a time has reached the limit. Use the enum name rather than the enum value.  |
991| CUSTOM_ERROR            | 1000 | Customized error. Error codes smaller than **1000** are used to define internal error codes, and error codes greater than **1000** are used to customize error codes. Use the enum name rather than the enum value.|
992
993### Result&lt;T&gt;<sup>11+</sup>
994
995Represents the device-cloud sharing result.
996
997**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
998
999| Name         | Type                         | Mandatory | Description          |
1000| ----------- | --------------------------- | --- | ------------ |
1001| code        | number                      | Yes  | Error code.      |
1002| description | string                      | No  | Detailed description of the error code. The default value is **undefined**.      |
1003| value       | T                           | No  | Value returned. The specific type is specified by the **T** parameter. The default value is **undefined**.|
1004
1005### Privilege<sup>11+</sup>
1006
1007Defines the privilege (permissions) on the shared data.
1008
1009**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1010
1011| Name         | Type                         | Mandatory | Description          |
1012| ----------- | --------------------------- | --- | ------------ |
1013| writable    | boolean              | No  | Whether the participant can modify the shared data. The value **true** means the participant can modify the data; the value **false** means the opposite. The default value is **false**.  |
1014| readable    | boolean              | No  | Whether the participant can read the shared data. The value **true** means the participant can read the data; the value **false** means the opposite. The default value is **false**.  |
1015| creatable   | boolean              | No  | Whether the participant can create data to share. The value **true** means the participant can create data; the value **false** means the opposite. The default value is **false**. |
1016| deletable   | boolean              | No  | Whether the participant can delete the shared data. The value **true** means the participant can delete the data; the value **false** means the opposite. The default value is **false**. |
1017| shareable   | boolean              | No  | Whether the participant can share the data to others. The value **true** means the participant can share the data; the value **false** means the opposite. The default value is **false**. |
1018
1019### Participant<sup>11+</sup>
1020
1021Represents information about a participant of device-cloud sharing.
1022
1023**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1024
1025| Name         | Type                         | Mandatory | Description          |
1026| ----------- | --------------------------- | --- | ------------ |
1027| identity    | string                  | Yes  | ID of the participant.             |
1028| role        | [Role](#role11)           | No  | Role of the participant, inviter or invitee. The default value is **undefined**. |
1029| state       | [State](#state11)         | No  | State of the device-cloud sharing. The default value is **undefined**.|
1030| privilege   | [Privilege](#privilege11) | No  | Permissions on the shared data. The [Privilege](#privilege11) defaults are used by default.|
1031| attachInfo  | string                  | No  | Additional information, such as the verification code used for participant identity verification. The default value is an empty string.|
1032
1033### allocResourceAndShare<sup>11+</sup>
1034
1035allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns?: Array&lt;string&gt;): Promise&lt;relationalStore.ResultSet&gt;
1036
1037Allocates a shared resource ID based on the data that matches the specified predicates. This API uses a promise to return the result set of the data to share, which also includes the column names if they are specified.
1038
1039**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1040
1041**Parameters**
1042
1043| Name   | Type                           | Mandatory| Description                        |
1044| --------- | ------------------------------- | ---- | ---------------------------- |
1045| storeId      | string                        | Yes  | Name of the RDB store.|
1046| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes  | Predicates for matching the data to share.|
1047| participants | Array&lt;[Participant](#participant11)&gt; | Yes  | Participants of the share.|
1048| columns      | Array&lt;string&gt;           | No  | Columns in which the data is located. The default value is **undefined**, which means column names are not returned.|
1049
1050**Return value**
1051
1052| Type               | Description                     |
1053| ------------------- | ------------------------- |
1054| Promise&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt; | Promise used to return the result set of the data to share.|
1055
1056**Error codes**
1057
1058For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1059
1060| ID| Error Message                                            |
1061| -------- | ---------------------------------------------------- |
1062| 202      | Permission verification failed, application which is not a system application uses system API.|
1063| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1064| 801      | Capability not supported.|
1065
1066**Example**
1067
1068```ts
1069import { BusinessError } from '@kit.BasicServicesKit';
1070import { relationalStore } from '@kit.ArkData';
1071
1072let participants = new Array<cloudData.sharing.Participant>();
1073participants.push({
1074  identity: '000000000',
1075  role: cloudData.sharing.Role.ROLE_INVITER,
1076  state: cloudData.sharing.State.STATE_UNKNOWN,
1077  privilege: {
1078    writable: true,
1079    readable: true,
1080    creatable: false,
1081    deletable: false,
1082    shareable: false
1083  },
1084  attachInfo: ''
1085})
1086let sharingResource: string;
1087let predicates = new relationalStore.RdbPredicates('test_table');
1088predicates.equalTo('data', 'data_test');
1089cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data']).then((resultSet) => {
1090  if (!resultSet.goToFirstRow()) {
1091    console.error(`row error`);
1092    return;
1093  }
1094  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1095  console.info(`sharing resource: ${res}`);
1096  sharingResource = res;
1097}).catch((err: BusinessError) => {
1098  console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1099})
1100
1101```
1102
1103### allocResourceAndShare<sup>11+</sup>
1104
1105allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1106
1107Allocates a shared resource ID based on the data that matches the specified predicates. This API uses an asynchronous callback to return the result set of the data to share, which includes the shared resource ID and column names.
1108
1109**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1110
1111**Parameters**
1112
1113| Name   | Type                           | Mandatory| Description                        |
1114| --------- | ------------------------------- | ---- | ---------------------------- |
1115| storeId      | string                        | Yes  | Name of the RDB store.|
1116| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes  | Predicates for matching the data to share.|
1117| participants | Array&lt;[Participant](#participant11)&gt; | Yes  | Participants of the share.|
1118| columns      | Array&lt;string&gt;           | Yes  | Columns in which the data is located.|
1119| callback     | AsyncCallback&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt;  | Yes | Callback used to return the result set of the data to share.|
1120
1121**Error codes**
1122
1123For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1124
1125| ID| Error Message                                            |
1126| -------- | ---------------------------------------------------- |
1127| 202      | Permission verification failed, application which is not a system application uses system API.|
1128| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1129| 801      | Capability not supported.|
1130
1131**Example**
1132
1133```ts
1134import { relationalStore } from '@kit.ArkData';
1135import { BusinessError } from '@kit.BasicServicesKit';
1136
1137let participants = new Array<cloudData.sharing.Participant>();
1138participants.push({
1139  identity: '000000000',
1140  role: cloudData.sharing.Role.ROLE_INVITER,
1141  state: cloudData.sharing.State.STATE_UNKNOWN,
1142  privilege: {
1143    writable: true,
1144    readable: true,
1145    creatable: false,
1146    deletable: false,
1147    shareable: false
1148  },
1149  attachInfo: ''
1150})
1151let sharingResource: string;
1152let predicates = new relationalStore.RdbPredicates('test_table');
1153predicates.equalTo('data', 'data_test');
1154cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data'], (err: BusinessError, resultSet) => {
1155  if (err) {
1156    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1157    return;
1158  }
1159  if (!resultSet.goToFirstRow()) {
1160    console.error(`row error`);
1161    return;
1162  }
1163  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1164  console.info(`sharing resource: ${res}`);
1165  sharingResource = res;
1166})
1167
1168```
1169
1170### allocResourceAndShare<sup>11+</sup>
1171
1172allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1173
1174Allocates a shared resource ID based on the data that matches the specified predicates. This API uses an asynchronous callback to return the result.
1175
1176**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1177
1178**Parameters**
1179
1180| Name   | Type                           | Mandatory| Description                        |
1181| --------- | ------------------------------- | ---- | ---------------------------- |
1182| storeId      | string                        | Yes  | Name of the RDB store.|
1183| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | Yes  | Predicates for matching the data to share.|
1184| participants | Array&lt;[Participant](#participant11)&gt; | Yes  | Participants of the share.|
1185| callback     | AsyncCallback&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt;  | Yes  | Callback used to return the result set of the data to share.|
1186
1187**Error codes**
1188
1189For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1190
1191| ID| Error Message                                            |
1192| -------- | ---------------------------------------------------- |
1193| 202      | Permission verification failed, application which is not a system application uses system API.|
1194| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1195| 801      | Capability not supported.|
1196
1197**Example**
1198
1199```ts
1200import { relationalStore } from '@kit.ArkData';
1201import { BusinessError } from '@kit.BasicServicesKit';
1202
1203let participants = new Array<cloudData.sharing.Participant>();
1204participants.push({
1205  identity: '000000000',
1206  role: cloudData.sharing.Role.ROLE_INVITER,
1207  state: cloudData.sharing.State.STATE_UNKNOWN,
1208  privilege: {
1209    writable: true,
1210    readable: true,
1211    creatable: false,
1212    deletable: false,
1213    shareable: false
1214  },
1215  attachInfo: ''
1216})
1217let sharingResource: string;
1218let predicates = new relationalStore.RdbPredicates('test_table');
1219predicates.equalTo('data', 'data_test');
1220cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, (err: BusinessError, resultSet) => {
1221  if (err) {
1222    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1223    return;
1224  }
1225  if (!resultSet.goToFirstRow()) {
1226    console.error(`row error`);
1227    return;
1228  }
1229  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1230  console.info(`sharing resource: ${res}`);
1231  sharingResource = res;
1232})
1233
1234```
1235
1236### share<sup>11+</sup>
1237
1238share(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1239
1240Shares data based on the specified shared resource ID and participants. This API uses a promise to return the result.
1241
1242**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1243
1244**Parameters**
1245
1246| Name   | Type                           | Mandatory| Description                        |
1247| --------- | ------------------------------- | ---- | ---------------------------- |
1248| sharingResource   | string                                     | Yes  | Shared resource ID.|
1249| participants      | Array&lt;[Participant](#participant11)&gt;   | Yes  | Participants of the share.|
1250
1251**Return value**
1252
1253| Type               | Description                     |
1254| ------------------- | ------------------------- |
1255| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise used to return the result.|
1256
1257**Error codes**
1258
1259For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1260
1261| ID| Error Message                                            |
1262| -------- | ---------------------------------------------------- |
1263| 202      | Permission verification failed, application which is not a system application uses system API.|
1264| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1265| 801      | Capability not supported.|
1266
1267**Example**
1268
1269```ts
1270import { BusinessError } from '@kit.BasicServicesKit';
1271
1272let participants = new Array<cloudData.sharing.Participant>();
1273participants.push({
1274  identity: '000000000',
1275  role: cloudData.sharing.Role.ROLE_INVITER,
1276  state: cloudData.sharing.State.STATE_UNKNOWN,
1277  privilege: {
1278    writable: true,
1279    readable: true,
1280    creatable: false,
1281    deletable: false,
1282    shareable: false
1283  },
1284  attachInfo: ''
1285})
1286cloudData.sharing.share('sharing_resource_test', participants).then((result) => {
1287  console.info(`share success, result: ${result}`);
1288}).catch((err: BusinessError) => {
1289  console.error(`share failed, code is ${err.code},message is ${err.message}`);
1290})
1291
1292```
1293
1294### share<sup>11+</sup>
1295
1296share(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1297
1298Shares data based on the specified shared resource ID and participants. This API uses an asynchronous callback to return the result.
1299
1300**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1301
1302**Parameters**
1303
1304| Name   | Type                           | Mandatory| Description                        |
1305| --------- | ------------------------------- | ---- | ---------------------------- |
1306| sharingResource  | string                                     | Yes  | Shared resource ID.|
1307| participants     | Array&lt;[Participant](#participant11)&gt; | Yes  | Participants of the share.|
1308| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | Yes  | Callback used to return the result.  |
1309
1310**Error codes**
1311
1312For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1313
1314| ID| Error Message                                            |
1315| -------- | ---------------------------------------------------- |
1316| 202      | Permission verification failed, application which is not a system application uses system API.|
1317| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1318| 801      | Capability not supported.|
1319
1320**Example**
1321
1322```ts
1323import { BusinessError } from '@kit.BasicServicesKit';
1324
1325let participants = new Array<cloudData.sharing.Participant>();
1326participants.push({
1327  identity: '000000000',
1328  role: cloudData.sharing.Role.ROLE_INVITER,
1329  state: cloudData.sharing.State.STATE_UNKNOWN,
1330  privilege: {
1331    writable: true,
1332    readable: true,
1333    creatable: false,
1334    deletable: false,
1335    shareable: false
1336  },
1337  attachInfo: ''
1338})
1339cloudData.sharing.share('sharing_resource_test', participants, ((err: BusinessError, result) => {
1340  if (err) {
1341    console.error(`share failed, code is ${err.code},message is ${err.message}`);
1342    return;
1343  }
1344  console.info(`share succeeded, result: ${result}`);
1345}))
1346
1347```
1348
1349### unshare<sup>11+</sup>
1350
1351unshare(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1352
1353Unshares data based on the specified shared resource ID and participants. This API uses a promise to return the result.
1354
1355**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1356
1357**Parameters**
1358
1359| Name   | Type                           | Mandatory| Description                        |
1360| --------- | ------------------------------- | ---- | ---------------------------- |
1361| sharingResource   | string                                     | Yes  | Shared resource ID.|
1362| participants      | Array&lt;[Participant](#participant11)&gt; | Yes  | Participants of the share.|
1363
1364**Return value**
1365
1366| Type               | Description                     |
1367| ------------------- | ------------------------- |
1368| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise used to return the result.|
1369
1370**Error codes**
1371
1372For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1373
1374| ID| Error Message                                            |
1375| -------- | ---------------------------------------------------- |
1376| 202      | Permission verification failed, application which is not a system application uses system API.|
1377| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1378| 801      | Capability not supported.|
1379
1380**Example**
1381
1382```ts
1383import { BusinessError } from '@kit.BasicServicesKit';
1384
1385let participants = new Array<cloudData.sharing.Participant>();
1386participants.push({
1387  identity: '000000000',
1388  role: cloudData.sharing.Role.ROLE_INVITER,
1389  state: cloudData.sharing.State.STATE_UNKNOWN,
1390  privilege: {
1391    writable: true,
1392    readable: true,
1393    creatable: false,
1394    deletable: false,
1395    shareable: false
1396  },
1397  attachInfo: ''
1398})
1399cloudData.sharing.unshare('sharing_resource_test', participants).then((result) => {
1400  console.info(`unshare succeeded, result: ${result}`);
1401}).catch((err: BusinessError) => {
1402  console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1403})
1404
1405```
1406
1407### unshare<sup>11+</sup>
1408
1409unshare(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1410
1411Unshares data based on the specified shared resource ID and participants. This API uses an asynchronous callback to return the result.
1412
1413**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1414
1415**Parameters**
1416
1417| Name   | Type                           | Mandatory| Description                        |
1418| --------- | ------------------------------- | ---- | ---------------------------- |
1419| sharingResource  | string                                     | Yes  | Shared resource ID.|
1420| participants     | Array&lt;[Participant](#participant11)&gt; | Yes  | Participants of the share.|
1421| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | Yes  | Callback used to return the result.  |
1422
1423**Error codes**
1424
1425For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1426
1427| ID| Error Message                                            |
1428| -------- | ---------------------------------------------------- |
1429| 202      | Permission verification failed, application which is not a system application uses system API.|
1430| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1431| 801      | Capability not supported.|
1432
1433**Example**
1434
1435```ts
1436import { BusinessError } from '@kit.BasicServicesKit';
1437
1438let participants = new Array<cloudData.sharing.Participant>();
1439participants.push({
1440  identity: '000000000',
1441  role: cloudData.sharing.Role.ROLE_INVITER,
1442  state: cloudData.sharing.State.STATE_UNKNOWN,
1443  privilege: {
1444    writable: true,
1445    readable: true,
1446    creatable: false,
1447    deletable: false,
1448    shareable: false
1449  },
1450  attachInfo: ''
1451})
1452cloudData.sharing.unshare('sharing_resource_test', participants, ((err: BusinessError, result) => {
1453  if (err) {
1454    console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1455    return;
1456  }
1457  console.info(`unshare succeeded, result: ${result}`);
1458}))
1459
1460```
1461
1462### exit<sup>11+</sup>
1463
1464exit(sharingResource: string): Promise&lt;Result&lt;void&gt;&gt;
1465
1466Exits the share of the specified shared resource. This API uses a promise to return the result.
1467
1468**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1469
1470**Parameters**
1471
1472| Name   | Type                           | Mandatory| Description                        |
1473| --------- | ------------------------------- | ---- | ---------------------------- |
1474| sharingResource   | string       | Yes  | Shared resource ID.|
1475
1476**Return value**
1477
1478| Type               | Description                     |
1479| ------------------- | ------------------------- |
1480| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; | Promise used to return the result.|
1481
1482**Error codes**
1483
1484For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1485
1486| ID| Error Message                                            |
1487| -------- | ---------------------------------------------------- |
1488| 202      | Permission verification failed, application which is not a system application uses system API.|
1489| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1490| 801      | Capability not supported.|
1491
1492**Example**
1493
1494```ts
1495import { BusinessError } from '@kit.BasicServicesKit';
1496
1497cloudData.sharing.exit('sharing_resource_test').then((result) => {
1498  console.info(`exit share success, result: ${result}`);
1499}).catch((err: BusinessError) => {
1500  console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1501})
1502
1503```
1504
1505### exit<sup>11+</sup>
1506
1507exit(sharingResource: string, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void
1508
1509Exits the share of the specified shared resource. This API uses an asynchronous callback to return the result.
1510
1511**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1512
1513**Parameters**
1514
1515| Name   | Type                           | Mandatory| Description                        |
1516| --------- | ------------------------------- | ---- | ---------------------------- |
1517| sharingResource  | string                | Yes  | Shared resource ID.|
1518| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt;  | Yes  | Callback used to return the result.  |
1519
1520**Error codes**
1521
1522For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1523
1524| ID| Error Message                                            |
1525| -------- | ---------------------------------------------------- |
1526| 202      | Permission verification failed, application which is not a system application uses system API.|
1527| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1528| 801      | Capability not supported.|
1529
1530**Example**
1531
1532```ts
1533import { BusinessError } from '@kit.BasicServicesKit';
1534
1535cloudData.sharing.exit('sharing_resource_test', ((err: BusinessError, result) => {
1536  if (err) {
1537    console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1538    return;
1539  }
1540  console.info(`exit share succeeded, result: ${result}`);
1541}))
1542
1543```
1544
1545### changePrivilege<sup>11+</sup>
1546
1547changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1548
1549Changes the privilege on the shared data. This API uses a promise to return the result.
1550
1551**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1552
1553**Parameters**
1554
1555| Name   | Type                           | Mandatory| Description                        |
1556| --------- | ------------------------------- | ---- | ---------------------------- |
1557| sharingResource   | string                                    | Yes  | Shared resource ID.|
1558| participants      | Array&lt;[Participant](#participant11)&gt;  | Yes  | Participants with new privilege.|
1559
1560**Return value**
1561
1562| Type               | Description                     |
1563| ------------------- | ------------------------- |
1564| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise used to return the result.|
1565
1566**Error codes**
1567
1568For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1569
1570| ID| Error Message                                            |
1571| -------- | ---------------------------------------------------- |
1572| 202      | Permission verification failed, application which is not a system application uses system API.|
1573| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1574| 801      | Capability not supported.|
1575
1576**Example**
1577
1578```ts
1579import { BusinessError } from '@kit.BasicServicesKit';
1580
1581let participants = new Array<cloudData.sharing.Participant>();
1582participants.push({
1583  identity: '000000000',
1584  role: cloudData.sharing.Role.ROLE_INVITER,
1585  state: cloudData.sharing.State.STATE_UNKNOWN,
1586  privilege: {
1587    writable: true,
1588    readable: true,
1589    creatable: false,
1590    deletable: false,
1591    shareable: false
1592  },
1593  attachInfo: ''
1594})
1595
1596cloudData.sharing.changePrivilege('sharing_resource_test', participants).then((result) => {
1597  console.info(`change privilege succeeded, result: ${result}`);
1598}).catch((err: BusinessError) => {
1599  console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1600})
1601
1602```
1603
1604### changePrivilege<sup>11+</sup>
1605
1606changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1607
1608Changes the privilege on the shared data. This API uses an asynchronous callback to return the result.
1609
1610**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1611
1612**Parameters**
1613
1614| Name   | Type                           | Mandatory| Description                        |
1615| --------- | ------------------------------- | ---- | ---------------------------- |
1616| sharingResource  | string                | Yes  | Shared resource ID.|
1617| participants     | Array&lt;[Participant](#participant11)&gt;  | Yes  | Participants with new privilege.|
1618| callback         | callback: AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | Yes  | Callback used to return the result.  |
1619
1620**Error codes**
1621
1622For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1623
1624| ID| Error Message                                            |
1625| -------- | ---------------------------------------------------- |
1626| 202      | Permission verification failed, application which is not a system application uses system API.|
1627| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1628| 801      | Capability not supported.|
1629
1630**Example**
1631
1632```ts
1633import { BusinessError } from '@kit.BasicServicesKit';
1634
1635let participants = new Array<cloudData.sharing.Participant>();
1636participants.push({
1637  identity: '000000000',
1638  role: cloudData.sharing.Role.ROLE_INVITER,
1639  state: cloudData.sharing.State.STATE_UNKNOWN,
1640  privilege: {
1641    writable: true,
1642    readable: true,
1643    creatable: false,
1644    deletable: false,
1645    shareable: false
1646  },
1647  attachInfo: ''
1648})
1649
1650cloudData.sharing.changePrivilege('sharing_resource_test', participants, ((err: BusinessError, result) => {
1651  if (err) {
1652    console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1653    return;
1654  }
1655  console.info(`change privilege succeeded, result: ${result}`);
1656}))
1657
1658```
1659
1660### queryParticipants<sup>11+</sup>
1661
1662queryParticipants(sharingResource: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1663
1664Queries the participants of the specified shared data. This API uses a promise to return the result.
1665
1666**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1667
1668**Parameters**
1669
1670| Name   | Type                           | Mandatory| Description                        |
1671| --------- | ------------------------------- | ---- | ---------------------------- |
1672| sharingResource   | string                 | Yes  | Shared resource ID.|
1673
1674**Return value**
1675
1676| Type               | Description                     |
1677| ------------------- | ------------------------- |
1678| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise used to return the participants obtained.|
1679
1680**Error codes**
1681
1682For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1683
1684| ID| Error Message                                            |
1685| -------- | ---------------------------------------------------- |
1686| 202      | Permission verification failed, application which is not a system application uses system API.|
1687| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1688| 801      | Capability not supported.|
1689
1690**Example**
1691
1692```ts
1693import { BusinessError } from '@kit.BasicServicesKit';
1694
1695cloudData.sharing.queryParticipants('sharing_resource_test').then((result) => {
1696  console.info(`query participants succeeded, result: ${result}`);
1697}).catch((err: BusinessError) => {
1698  console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1699})
1700
1701```
1702
1703### queryParticipants<sup>11+</sup>
1704
1705queryParticipants(sharingResource: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1706
1707Queries the participants of the specified shared data. This API uses an asynchronous callback to return the result.
1708
1709**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1710
1711**Parameters**
1712
1713| Name   | Type                           | Mandatory| Description                        |
1714| --------- | ------------------------------- | ---- | ---------------------------- |
1715| sharingResource  | string                | Yes  | Shared resource ID.|
1716| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt;  | Yes  | Callback used to return the participants obtained.|
1717
1718**Error codes**
1719
1720For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1721
1722| ID| Error Message                                            |
1723| -------- | ---------------------------------------------------- |
1724| 202      | Permission verification failed, application which is not a system application uses system API.|
1725| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1726| 801      | Capability not supported.|
1727
1728**Example**
1729
1730```ts
1731import { BusinessError } from '@kit.BasicServicesKit';
1732
1733cloudData.sharing.queryParticipants('sharing_resource_test', ((err: BusinessError, result) => {
1734  if (err) {
1735    console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1736    return;
1737  }
1738  console.info(`query participants succeeded, result: ${result}`);
1739}))
1740
1741```
1742
1743### queryParticipantsByInvitation<sup>11+</sup>
1744
1745queryParticipantsByInvitation(invitationCode: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1746
1747Queries the participants based on the sharing invitation code. This API uses a promise to return the result.
1748
1749**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1750
1751**Parameters**
1752
1753| Name   | Type                           | Mandatory| Description                        |
1754| --------- | ------------------------------- | ---- | ---------------------------- |
1755| invitationCode   | string                 | Yes  | Invitation code of the share.|
1756
1757**Return value**
1758
1759| Type               | Description                     |
1760| ------------------- | ------------------------- |
1761| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise used to return the participants obtained.|
1762
1763**Error codes**
1764
1765For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1766
1767| ID| Error Message                                            |
1768| -------- | ---------------------------------------------------- |
1769| 202      | Permission verification failed, application which is not a system application uses system API.|
1770| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1771| 801      | Capability not supported.|
1772
1773**Example**
1774
1775```ts
1776import { BusinessError } from '@kit.BasicServicesKit';
1777
1778cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test').then((result) => {
1779  console.info(`query participants by invitation succeeded, result: ${result}`);
1780}).catch((err: BusinessError) => {
1781  console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1782})
1783
1784```
1785
1786### queryParticipantsByInvitation<sup>11+</sup>
1787
1788queryParticipantsByInvitation(invitationCode: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1789
1790Queries the participants based on the sharing invitation code. This API uses an asynchronous callback to return the result.
1791
1792**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1793
1794**Parameters**
1795
1796| Name   | Type                           | Mandatory| Description                        |
1797| --------- | ------------------------------- | ---- | ---------------------------- |
1798| invitationCode  | string                | Yes  | Invitation code of the share.|
1799| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Yes  | Callback used to return the participants obtained.|
1800
1801**Error codes**
1802
1803For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1804
1805| ID| Error Message                                            |
1806| -------- | ---------------------------------------------------- |
1807| 202      | Permission verification failed, application which is not a system application uses system API.|
1808| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1809| 801      | Capability not supported.|
1810
1811**Example**
1812
1813```ts
1814import { BusinessError } from '@kit.BasicServicesKit';
1815
1816cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test', ((err: BusinessError, result) => {
1817  if (err) {
1818    console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1819    return;
1820  }
1821  console.info(`query participants by invitation succeeded, result: ${result}`);
1822}))
1823
1824```
1825
1826### confirmInvitation<sup>11+</sup>
1827
1828confirmInvitation(invitationCode: string, state: State): Promise&lt;Result&lt;string&gt;&gt;
1829
1830Confirms the invitation based on the sharing invitation code and obtains the shared resource ID. This API uses a promise to return the result.
1831
1832**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1833
1834**Parameters**
1835
1836| Name   | Type                           | Mandatory| Description                        |
1837| --------- | ------------------------------- | ---- | ---------------------------- |
1838| invitationCode   | string                 | Yes  | Invitation code of the share.|
1839| state            | [State](#state11)        | Yes  | Confirmation state.|
1840
1841**Return value**
1842
1843| Type               | Description                     |
1844| ------------------- | ------------------------- |
1845| Promise&lt;[Result](#resultt11)&lt;string&gt;&gt; | Promise used to return the result.|
1846
1847**Error codes**
1848
1849For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1850
1851| ID| Error Message                                            |
1852| -------- | ---------------------------------------------------- |
1853| 202      | Permission verification failed, application which is not a system application uses system API.|
1854| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1855| 801      | Capability not supported.|
1856
1857**Example**
1858
1859```ts
1860import { BusinessError } from '@kit.BasicServicesKit';
1861
1862let shareResource: string | undefined;
1863cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED).then((result: cloudData.sharing.Result<string>) => {
1864  console.info(`confirm invitation succeeded, result: ${result}`);
1865  shareResource = result.value;
1866}).catch((err: BusinessError) => {
1867  console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1868})
1869
1870```
1871
1872### confirmInvitation<sup>11+</sup>
1873
1874confirmInvitation(invitationCode: string, state: State, callback: AsyncCallback&lt;Result&lt;string&gt;&gt;): void
1875
1876Confirms the invitation based on the sharing invitation code and obtains the shared resource ID. This API uses an asynchronous callback to return the result.
1877
1878**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1879
1880**Parameters**
1881
1882| Name   | Type                           | Mandatory| Description                        |
1883| --------- | ------------------------------- | ---- | ---------------------------- |
1884| invitationCode  | string                | Yes  | Invitation code of the share.|
1885| state           | [State](#state11)       | Yes  | Confirmation state.|
1886| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;string&gt;&gt; | Yes  | Callback used to return the result.  |
1887
1888**Error codes**
1889
1890For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1891
1892| ID| Error Message                                            |
1893| -------- | ---------------------------------------------------- |
1894| 202      | Permission verification failed, application which is not a system application uses system API.|
1895| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1896| 801      | Capability not supported.|
1897
1898**Example**
1899
1900```ts
1901import { BusinessError } from '@kit.BasicServicesKit';
1902
1903let shareResource: string;
1904cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED, ((err: BusinessError, result) => {
1905  if (err) {
1906    console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1907    return;
1908  }
1909  console.info(`confirm invitation succeeded, result: ${result}`);
1910  shareResource = result.value;
1911}))
1912
1913```
1914
1915### changeConfirmation<sup>11+</sup>
1916
1917changeConfirmation(sharingResource: string, state: State): Promise&lt;Result&lt;void&gt;&gt;
1918
1919Changes the invitation confirmation state based on the shared resource ID. This API uses a promise to return the result.
1920
1921**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1922
1923**Parameters**
1924
1925| Name   | Type                           | Mandatory| Description                        |
1926| --------- | ------------------------------- | ---- | ---------------------------- |
1927| sharingResource   | string                 | Yes  | Shared resource ID.|
1928| state             | [State](#state11)        | Yes  | New confirmation state of the invitation.|
1929
1930**Return value**
1931
1932| Type               | Description                     |
1933| ------------------- | ------------------------- |
1934| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; |  Promise used to return the result.|
1935
1936**Error codes**
1937
1938For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1939
1940| ID| Error Message                                            |
1941| -------- | ---------------------------------------------------- |
1942| 202      | Permission verification failed, application which is not a system application uses system API.|
1943| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1944| 801      | Capability not supported.|
1945
1946**Example**
1947
1948```ts
1949import { BusinessError } from '@kit.BasicServicesKit';
1950
1951cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED).then((result) => {
1952  console.info(`change confirmation succeeded, result: ${result}`);
1953}).catch((err: BusinessError) => {
1954  console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
1955})
1956
1957```
1958
1959### changeConfirmation<sup>11+</sup>
1960
1961changeConfirmation(sharingResource: string, state: State, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void;
1962
1963Changes the invitation confirmation state based on the shared resource ID. This API uses an asynchronous callback to return the result.
1964
1965**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
1966
1967**Parameters**
1968
1969| Name   | Type                           | Mandatory| Description                        |
1970| --------- | ------------------------------- | ---- | ---------------------------- |
1971| sharingResource   | string                 | Yes  | Shared resource ID.|
1972| state             | [State](#state11)        | Yes  | New confirmation state of the invitation.|
1973| callback          | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt; | Yes  | Callback used to return the result.  |
1974
1975**Error codes**
1976
1977For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1978
1979| ID| Error Message                                            |
1980| -------- | ---------------------------------------------------- |
1981| 202      | Permission verification failed, application which is not a system application uses system API.|
1982| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1983| 801      | Capability not supported.|
1984
1985**Example**
1986
1987```ts
1988import { BusinessError } from '@kit.BasicServicesKit';
1989
1990cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED, ((err: BusinessError, result) => {
1991  if (err) {
1992    console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
1993    return;
1994  }
1995  console.info(`change confirmation succeeded, result: ${result}`);
1996}))
1997
1998```
1999<!--no_check-->
2000