• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.cloudData (端云服务)(系统接口)
2
3端云服务提供端云协同、端云共享和端云策略。
4
5端云协同提供结构化数据(RDB Store)端云同步的能力。即:云作为数据的中心节点,通过与云的数据同步,实现数据云备份、同账号设备间的数据一致性。
6
7端云共享是在端云协同能力基础上,实现跨账号的数据共享。其中,端云共享资源标识是指:对于应用发起共享的每一条数据记录,该条数据在进行端云同步时会生成唯一的共享资源标识(字符串类型的值),此标识则作为该条数据记录共享时的识别标识。
8
9端云共享参与者是指: 共享发起者根据好友列表选中的参与当前数据共享的所有人员。
10
11端云共享邀请码是指: 共享发起后,在共享的服务端会生成当前共享操作的邀请码,并将该邀请码附加到当前共享邀请中,通过push消息推送到被邀请者的设备端,被邀请者可以通过该邀请码进行邀请的确认。
12
13该模块提供以下端云服务相关的常用功能:
14
15- [Config](#config):提供配置端云协同的方法,包括云同步打开、关闭、清理数据、数据变化通知。
16- [sharing](#sharing11):提供端云共享的方法,包括发起共享、取消共享、退出共享、更改共享数据权限、查找共享参与者、确认邀请、更改已确认的邀请、查找共享资源。
17
18> **说明:**
19>
20> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
21>
22> - 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.data.cloudData (端云服务)](js-apis-data-cloudData.md)。
23>
24> - 使用本模块需要实现云服务功能。
25
26## 导入模块
27
28```ts
29import { cloudData } from '@kit.ArkData';
30```
31
32## ClearAction
33
34清除本地下载的云端数据的行为枚举。
35
36**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
37
38| 名称      | 说明                         |
39| --------- | ---------------------------- |
40| CLEAR_CLOUD_INFO | 清除从云端下载的数据的云标识,相关数据作为本地数据保存。 |
41| CLEAR_CLOUD_DATA_AND_INFO |清除从云端下载的数据,不包括本地已修改的云端数据。   |
42
43## ExtraData<sup>11+</sup>
44
45透传数据,携带通知数据变更所需要的信息。
46
47**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
48
49| 名称      | 类型   | 必填 | 说明                                                         |
50| --------- | ------ | ---- | ------------------------------------------------------------ |
51| eventId   | string | 是   | 如果传值为"cloud_data_change",表示云数据变更。              |
52| extraData | string | 是   | 透传数据,extraData是json结构的字符串,其中必须包括"data"字段,"data"中是通知变更所需要的信息,包含账号、应用名、数据库名、数据库类型和数据库表名,所有字段均不能为空。
53
54**示例:**
55
56```ts
57// accountId:用户打开的云账号ID
58// bundleName:应用包名
59// containerName:云上数据库名称
60// databaseScopes:云上数据库类型
61// recordTypes:云上数据库表名
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
80返回数据,携带端云同步统计信息所需要的信息。
81
82**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
83
84| 名称      | 类型   | 必填 | 说明                                                  |
85| --------- | ------ | ---- |-----------------------------------------------------|
86| table   | string | 是   | 查询的表名。如返回值为"cloud_notes",表示查询结果是表名为"cloud_notes"的同步信息。 |
87| inserted   | number | 是   | 本地新增且云端还未同步数据的条数,如返回值为2,表示本地新增2条数据且云端还未同步。          |
88| updated   | number | 是   | 云端同步之后本地或云端修改还未同步的条数,如返回值为2,表示本地或云端修改还有2条数据未同步。     |
89| normal | number | 是   | 端云一致的数据。如返回值为2,表示本地与云端一致的数据为2条。                     |
90
91## SyncStatus<sup>18+</sup>
92
93端云同步任务的状态。
94
95**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
96
97| 名称      | 值   | 说明              |
98| -------- |-----|-----------------|
99| RUNNING | 0  | 表示端云同步任务处于运行状态。 |
100| FINISHED | 1   | 表示端云同步任务处于完成状态。 |
101
102## SyncInfo<sup>12+</sup>
103
104返回数据,最近一次端云同步所需要的信息。
105
106**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
107
108| 名称       | 类型                                                         | 必填 | 说明                       |
109| ---------- | ------------------------------------------------------------ | ---- | -------------------------- |
110| startTime  | Date                                                         | 是   | 最近一次端云同步的开始时间。 |
111| finishTime | Date                                                         | 是   | 最近一次端云同步的结束时间。 |
112| code       | [relationalStore.ProgressCode](js-apis-data-relationalStore.md#progresscode10) | 是   | 最近一次端云同步的结果。 |
113| syncStatus<sup>18+</sup> | [SyncStatus](#syncstatus18) | 否 | 最近一次端云同步的状态,默认值cloudData.SyncStatus.RUNNING。 |
114
115## Config
116
117提供配置端云协同的方法,包括云同步打开、关闭、清理数据、数据变化通知。
118
119### enableCloud
120
121static enableCloud(accountId: string, switches: Record<string, boolean>, callback: AsyncCallback&lt;void&gt;): void
122
123打开端云协同,使用callback异步回调。
124
125**需要权限**:ohos.permission.CLOUDDATA_CONFIG
126
127**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
128
129**参数:**
130
131| 参数名    | 类型                            | 必填 | 说明                                                         |
132| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
133| accountId | string                          | 是   | 具体打开的云账号ID。                                         |
134| switches  | Record<string, boolean>         | 是   | 各应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
135| callback  | AsyncCallback&lt;void&gt;       | 是   | 回调函数。                                                   |
136
137**错误码:**
138
139以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
140
141| 错误码ID | 错误信息                                             |
142| -------- | ---------------------------------------------------- |
143| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
144| 202      | Permission verification failed, application which is not a system application uses system API.|
145| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
146| 801      | Capability not supported.|
147
148**示例:**
149
150```ts
151import { BusinessError } from '@kit.BasicServicesKit';
152
153let account: string = 'test_id';
154let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
155try {
156  cloudData.Config.enableCloud(account, switches, (err: BusinessError) => {
157    if (err === undefined) {
158      console.info('Succeeded in enabling cloud');
159    } else {
160      console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
161    }
162  });
163} catch (e) {
164  let error = e as BusinessError;
165  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
166}
167```
168
169### enableCloud
170
171static enableCloud(accountId: string, switches: Record<string, boolean>): Promise&lt;void&gt;
172
173打开端云协同,使用Promise异步回调。
174
175**需要权限**:ohos.permission.CLOUDDATA_CONFIG
176
177**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
178
179**参数:**
180
181| 参数名    | 类型                            | 必填 | 说明                                                         |
182| --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
183| accountId | string                          | 是   | 具体打开的云账号ID。                                         |
184| switches  | Record<string, boolean>         | 是   | 各应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
185
186**返回值:**
187
188| 类型                | 说明                      |
189| ------------------- | ------------------------- |
190| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
191
192**错误码:**
193
194以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
195
196| 错误码ID | 错误信息                                             |
197| -------- | ---------------------------------------------------- |
198| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
199| 202      | Permission verification failed, application which is not a system application uses system API.|
200| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
201| 801      | Capability not supported.|
202
203**示例:**
204
205```ts
206import { BusinessError } from '@kit.BasicServicesKit';
207
208let account: string = 'test_id';
209let switches: Record<string, boolean> = { 'test_bundleName1': true, 'test_bundleName2': false };
210try {
211  cloudData.Config.enableCloud(account, switches).then(() => {
212    console.info('Succeeded in enabling cloud');
213  }).catch((err: BusinessError) => {
214    console.error(`Failed to enable.Code: ${err.code}, message: ${err.message}`);
215  });
216} catch (e) {
217  let error = e as BusinessError;
218  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
219}
220```
221
222### disableCloud
223
224static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;): void
225
226关闭端云协同,使用callback异步回调。
227
228**需要权限**:ohos.permission.CLOUDDATA_CONFIG
229
230**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
231
232**参数:**
233
234| 参数名    | 类型                      | 必填 | 说明                 |
235| --------- | ------------------------- | ---- | -------------------- |
236| accountId | string                    | 是   | 具体打开的云账号ID。 |
237| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
238
239**错误码:**
240
241以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
242
243| 错误码ID | 错误信息                                             |
244| -------- | ---------------------------------------------------- |
245| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
246| 202      | Permission verification failed, application which is not a system application uses system API.|
247| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
248| 801      | Capability not supported.|
249
250**示例:**
251
252```ts
253import { BusinessError } from '@kit.BasicServicesKit';
254
255let account: string = 'test_id';
256try {
257  cloudData.Config.disableCloud(account, (err: BusinessError) => {
258    if (err === undefined) {
259      console.info('Succeeded in disabling cloud');
260    } else {
261      console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
262    }
263  });
264} catch (e) {
265  let error = e as BusinessError;
266  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
267}
268```
269
270### disableCloud
271
272static disableCloud(accountId: string): Promise&lt;void&gt;
273
274关闭端云协同,使用Promise异步回调。
275
276**需要权限**:ohos.permission.CLOUDDATA_CONFIG
277
278**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
279
280**参数:**
281
282| 参数名    | 类型   | 必填 | 说明                 |
283| --------- | ------ | ---- | -------------------- |
284| accountId | string | 是   | 具体打开的云账号ID。 |
285
286**返回值:**
287
288| 类型                | 说明                      |
289| ------------------- | ------------------------- |
290| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
291
292**错误码:**
293
294以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
295
296| 错误码ID | 错误信息                                             |
297| -------- | ---------------------------------------------------- |
298| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
299| 202      | Permission verification failed, application which is not a system application uses system API.|
300| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
301| 801      | Capability not supported.|
302
303**示例:**
304
305```ts
306import { BusinessError } from '@kit.BasicServicesKit';
307
308let account: string = 'test_id';
309try {
310  cloudData.Config.disableCloud(account).then(() => {
311    console.info('Succeeded in disabling cloud');
312  }).catch((err: BusinessError) => {
313    console.error(`Failed to disableCloud. Code: ${err.code}, message: ${err.message}`);
314  });
315} catch (e) {
316  let error = e as BusinessError;
317  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
318}
319```
320
321### changeAppCloudSwitch
322
323static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean, callback: AsyncCallback&lt;void&gt;): void
324
325修改单个应用端云协同开关,使用callback异步回调。
326
327**需要权限**:ohos.permission.CLOUDDATA_CONFIG
328
329**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
330
331**参数:**
332
333| 参数名    | 类型                            | 必填 | 说明                         |
334| --------- | ------------------------------- | ---- | ---------------------------- |
335| accountId | string                          | 是   | 具体打开的云账号ID。 |
336| bundleName| string                         | 是   | 应用名。 |
337| status    | boolean                        | 是   | 应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
338| callback  | AsyncCallback&lt;void&gt;       | 是   | 回调函数。                   |
339
340**错误码:**
341
342以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
343
344| 错误码ID | 错误信息                                             |
345| -------- | ---------------------------------------------------- |
346| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
347| 202      | Permission verification failed, application which is not a system application uses system API.|
348| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
349| 801      | Capability not supported.|
350
351**示例:**
352
353```ts
354import { BusinessError } from '@kit.BasicServicesKit';
355
356let account: string = 'test_id';
357let bundleName: string = 'test_bundleName';
358try {
359  cloudData.Config.changeAppCloudSwitch(account, bundleName, true, (err: BusinessError) => {
360    if (err === undefined) {
361      console.info('Succeeded in changing App cloud switch');
362    } else {
363      console.error(`Failed to change App cloud switch. Code: ${err.code}, message: ${err.message}`);
364    }
365  });
366} catch (e) {
367  let error = e as BusinessError;
368  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
369}
370```
371
372### changeAppCloudSwitch
373
374static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise&lt;void&gt;
375
376修改单个应用端云协同开关,使用Promise异步回调。
377
378**需要权限**:ohos.permission.CLOUDDATA_CONFIG
379
380**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
381
382**参数:**
383
384| 参数名    | 类型                            | 必填 | 说明                         |
385| --------- | ------------------------------- | ---- | ---------------------------- |
386| accountId | string                          | 是   | 具体打开的云账号ID。 |
387| bundleName| string                         | 是   | 应用名。 |
388| status    | boolean                        | 是   | 应用的端云协同开关信息。true为打开该应用端云开关,false为关闭该应用端云开关。 |
389
390**返回值:**
391
392| 类型                | 说明                      |
393| ------------------- | ------------------------- |
394| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
395
396**错误码:**
397
398以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
399
400| 错误码ID | 错误信息                                             |
401| -------- | ---------------------------------------------------- |
402| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
403| 202      | Permission verification failed, application which is not a system application uses system API.|
404| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
405| 801      | Capability not supported.|
406
407**示例:**
408
409```ts
410import { BusinessError } from '@kit.BasicServicesKit';
411
412let account: string = 'test_id';
413let bundleName: string = 'test_bundleName';
414try {
415  cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
416    console.info('Succeeded in changing App cloud switch');
417  }).catch((err: BusinessError) => {
418    console.error(`Failed to change App cloud switch. Code is ${err.code}, message is ${err.message}`);
419  });
420} catch (e) {
421  let error = e as BusinessError;
422  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
423}
424```
425
426### notifyDataChange
427
428static notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
429
430通知云端的数据变更,使用callback异步回调。
431
432**需要权限**:ohos.permission.CLOUDDATA_CONFIG
433
434**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
435
436**参数:**
437
438| 参数名     | 类型                      | 必填 | 说明                 |
439| ---------- | ------------------------- | ---- | -------------------- |
440| accountId  | string                    | 是   | 具体打开的云账号ID。 |
441| bundleName | string                    | 是   | 应用名。             |
442| callback   | AsyncCallback&lt;void&gt; | 是   | 回调函数。           |
443
444**错误码:**
445
446以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
447
448| 错误码ID | 错误信息                                             |
449| -------- | ---------------------------------------------------- |
450| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
451| 202      | Permission verification failed, application which is not a system application uses system API.|
452| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
453| 801      | Capability not supported.|
454
455**示例:**
456
457```ts
458import { BusinessError } from '@kit.BasicServicesKit';
459
460let account: string = 'test_id';
461let bundleName: string = 'test_bundleName';
462try {
463  cloudData.Config.notifyDataChange(account, bundleName, (err: BusinessError) => {
464    if (err === undefined) {
465      console.info('Succeeded in notifying the change of data');
466    } else {
467      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
468    }
469  });
470} catch (e) {
471  let error = e as BusinessError;
472  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
473}
474```
475
476### notifyDataChange
477
478static notifyDataChange(accountId: string,bundleName: string): Promise&lt;void&gt;
479
480通知云端的数据变更,使用Promise异步回调。
481
482**需要权限**:ohos.permission.CLOUDDATA_CONFIG
483
484**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
485
486**参数:**
487
488| 参数名     | 类型   | 必填 | 说明                 |
489| ---------- | ------ | ---- | -------------------- |
490| accountId  | string | 是   | 具体打开的云账号ID。 |
491| bundleName | string | 是   | 应用名。             |
492
493**返回值:**
494
495| 类型                | 说明                      |
496| ------------------- | ------------------------- |
497| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
498
499**错误码:**
500
501以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
502
503| 错误码ID | 错误信息                                             |
504| -------- | ---------------------------------------------------- |
505| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
506| 202      | Permission verification failed, application which is not a system application uses system API.|
507| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
508| 801      | Capability not supported.|
509
510**示例:**
511
512```ts
513import { BusinessError } from '@kit.BasicServicesKit';
514
515let account: string = 'test_id';
516let bundleName: string = 'test_bundleName';
517try {
518  cloudData.Config.notifyDataChange(account, bundleName).then(() => {
519    console.info('Succeeded in notifying the change of data');
520  }).catch((err: BusinessError) => {
521    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
522  });
523} catch (e) {
524  let error = e as BusinessError;
525  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
526}
527```
528
529### notifyDataChange<sup>11+</sup>
530
531 static notifyDataChange(extInfo: ExtraData, callback: AsyncCallback&lt;void&gt;):void
532
533通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,使用callback异步回调。
534
535**需要权限**:ohos.permission.CLOUDDATA_CONFIG
536
537**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
538
539**参数:**
540
541| 参数名   | 类型                      | 必填 | 说明                                    |
542| -------- | ------------------------- | ---- | --------------------------------------- |
543| extInfo  | [ExtraData](#extradata11)   | 是   | 透传数据,包含通知数据变更后的应用信息。 |
544| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当数据变更通知成功,err为undefined,否则为错误对象。|
545
546**错误码:**
547
548以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
549
550| 错误码ID | 错误信息                                             |
551| -------- | ---------------------------------------------------- |
552| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
553| 202      | Permission verification failed, application which is not a system application uses system API.|
554| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
555| 801      | Capability not supported.|
556
557**示例:**
558
559```ts
560import { BusinessError } from '@kit.BasicServicesKit';
561
562let eventId: string = "cloud_data_change";
563let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
564try {
565  cloudData.Config.notifyDataChange({
566    eventId: eventId, extraData: extraData
567  }, (err: BusinessError) => {
568    if (err === undefined) {
569      console.info('Succeeded in notifying the change of data');
570    } else {
571      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
572    }
573  });
574} catch (e) {
575  let error = e as BusinessError;
576  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
577}
578```
579
580### notifyDataChange<sup>11+</sup>
581
582static notifyDataChange(extInfo: ExtraData, userId: number,callback: AsyncCallback&lt;void&gt;):void
583
584通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,可通过userId指定用户ID,使用callback异步回调。
585
586**需要权限**:ohos.permission.CLOUDDATA_CONFIG
587
588**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
589
590**参数:**
591
592| 参数名   | 类型                      | 必填 | 说明                                            |
593| -------- | ------------------------- | ---- | ----------------------------------------------- |
594| extInfo  | [ExtraData](#extradata11)   | 是   | 透传数据,包含通知数据变更后的应用信息。        |
595| userId   | number                    | 是   | 用户ID。对应为系统中现有的用户ID。 |
596| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。当数据变更通知成功,err为undefined,否则为错误对象。|
597
598**错误码:**
599
600以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
601
602| 错误码ID | 错误信息                                             |
603| -------- | ---------------------------------------------------- |
604| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
605| 202      | Permission verification failed, application which is not a system application uses system API.|
606| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
607| 801      | Capability not supported.|
608
609**示例:**
610
611```ts
612import { BusinessError } from '@kit.BasicServicesKit';
613
614let eventId: string = "cloud_data_change";
615let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
616let userId: number = 100;
617try {
618  cloudData.Config.notifyDataChange({
619    eventId: eventId, extraData: extraData
620  }, userId, (err: BusinessError) => {
621    if (err === undefined) {
622      console.info('Succeeded in notifying the change of data');
623    } else {
624      console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
625    }
626  });
627} catch (e) {
628  let error = e as BusinessError;
629  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
630}
631```
632
633### notifyDataChange<sup>11+</sup>
634
635static notifyDataChange(extInfo: ExtraData, userId?: number): Promise&lt;void&gt;
636
637通知云端的数据变更,可以通过extInfo中的extraData字段指定变更的数据库名和表名,可通过userId指定用户ID,使用Promise异步回调。
638
639**需要权限**:ohos.permission.CLOUDDATA_CONFIG
640
641**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
642
643**参数:**
644
645| 参数名  | 类型                    | 必填 | 说明                                            |
646| ------- | ----------------------- | ---- | ----------------------------------------------- |
647| extInfo | [ExtraData](#extradata11) | 是   | 透传数据 包含通知数据变更后的应用信息。         |
648| userId  | number                  | 否   | 表示用户ID。此参数是可选的,默认值是当前用户ID,如果指定了此参数,则该值必须是系统中现有的用户ID。 |
649
650**返回值:**
651
652| 类型                | 说明                      |
653| ------------------- | ------------------------- |
654| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
655
656**错误码:**
657
658以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
659
660| 错误码ID | 错误信息                                             |
661| -------- | ---------------------------------------------------- |
662| 201      | Permission verification failed, which is usually returned by VerifyAccessToken.|
663| 202      | Permission verification failed, application which is not a system application uses system API.|
664| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
665| 801      | Capability not supported.|
666
667**示例:**
668
669```ts
670import { BusinessError } from '@kit.BasicServicesKit';
671
672let eventId: string = "cloud_data_change";
673let extraData: string = '{"data":"{"accountId":"aaa","bundleName":"com.bbb.xxx","containerName":"alias", "databaseScopes": ["private", "shared"],"recordTypes":"["xxx","yyy","zzz"]"}"}';
674let userId: number = 100;
675try {
676  cloudData.Config.notifyDataChange({
677    eventId: eventId, extraData: extraData
678  }, userId).then(() => {
679    console.info('Succeeded in notifying the change of data');
680  }).catch((err: BusinessError) => {
681    console.error(`Failed to notify the change of data. Code: ${err.code}, message: ${err.message}`);
682  });
683} catch (e) {
684  let error = e as BusinessError;
685  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
686}
687```
688
689### queryStatistics<sup>12+</sup>
690
691static queryStatistics(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record&lt;string, Array&lt;StatisticInfo&gt;&gt;&gt;
692
693查询端云统计信息,返回未同步、已同步且端云信息一致和已同步且端云信息不一致的统计信息,使用Promise异步回调。
694
695**需要权限**:ohos.permission.CLOUDDATA_CONFIG
696
697**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
698
699**参数:**
700
701| 参数名  | 类型      | 必填 | 说明                                |
702| ------- |---------| ---- |-----------------------------------|
703| accountId | string  | 是   | 具体打开的云账号ID。                       |
704| bundleName | string  | 是   | 应用包名。                             |
705| storeId  | string  | 否   | 数据库名称。默认值为空字符串,此时将查询当前应用所有的本地数据库。 |
706
707**返回值:**
708
709| 类型                                                                                   | 说明                     |
710|--------------------------------------------------------------------------------------| ------------------------ |
711| Promise&lt;Record&lt;string, Array&lt;[StatisticInfo](#statisticinfo12)&gt;&gt;&gt; | 返回表名以及统计信息结果集。 |
712
713**错误码:**
714
715以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
716
717| 错误码ID | 错误信息                                             |
718| -------- | ---------------------------------------------------- |
719| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
720| 202      | Permission verification failed, application which is not a system application uses system API.|
721| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
722| 801      | Capability not supported.|
723
724**示例:**
725
726```ts
727import { BusinessError } from '@kit.BasicServicesKit';
728
729const accountId:string = "accountId";
730const bundleName:string = "bundleName";
731const storeId:string = "storeId";
732
733cloudData.Config.queryStatistics(accountId, bundleName, storeId).then((result) => {
734    console.info(`Succeeded in querying statistics. Info is ${JSON.stringify(result)}`);
735}).catch((err: BusinessError) => {
736    console.error(`Failed to query statistics. Error code is ${err.code}, message is ${err.message}`);
737});
738```
739
740### queryLastSyncInfo<sup>12+</sup>
741
742static queryLastSyncInfo(accountId: string, bundleName: string, storeId?: string): Promise&lt;Record<string, SyncInfo>>
743
744查询上一次端云同步信息,使用Promise异步回调。
745
746**需要权限**:ohos.permission.CLOUDDATA_CONFIG
747
748**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
749
750**参数:**
751
752| 参数名     | 类型   | 必填 | 说明                                                         |
753| ---------- | ------ | ---- | ------------------------------------------------------------ |
754| accountId  | string | 是   | 具体打开的云账号ID。                                         |
755| bundleName | string | 是   | 应用包名。                                                   |
756| storeId    | string | 否   | 数据库名称。默认值为空字符串,此时查询当前应用下所有数据库上一次端云同步信息。 |
757
758**返回值:**
759
760| 类型                                                         | 说明                                         |
761| ------------------------------------------------------------ | -------------------------------------------- |
762| Promise&lt;Record&lt;string, [SyncInfo](#syncinfo12)&gt;&gt; | 返回数据库名以及上一次端云同步的信息结果集。 |
763
764**错误码:**
765
766以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
767
768| 错误码ID | 错误信息                                             |
769| -------- | ---------------------------------------------------- |
770| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
771| 202      | Permission verification failed, application which is not a system application uses system API.|
772| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
773| 801      | Capability not supported.|
774
775**示例:**
776
777```ts
778import { BusinessError } from '@kit.BasicServicesKit';
779
780const accountId:string = "accountId";
781const bundleName:string = "bundleName";
782const storeId:string = "storeId";
783try {
784    cloudData.Config.queryLastSyncInfo(accountId, bundleName, storeId).then((result) => {
785    	console.info(`Succeeded in querying last syncinfo. Info is ${JSON.stringify(result)}`);
786	}).catch((err: BusinessError) => {
787    	console.error(`Failed to query last syncinfo. Error code is ${err.code}, message is ${err.message}`);
788	});
789} catch(e) {
790    let error = e as BusinessError;
791  	console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
792}
793```
794
795### setGlobalCloudStrategy<sup>12+</sup>
796
797static setGlobalCloudStrategy(strategy: StrategyType, param?: Array&lt;commonType.ValueType&gt;): Promise&lt;void&gt;
798
799设置全局云同步策略,使用Promise异步回调。
800
801**需要权限**:ohos.permission.CLOUDDATA_CONFIG
802
803**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
804
805**参数:**
806
807| 参数名     | 类型                                                                     | 必填 | 说明                |
808| ---------- |------------------------------------------------------------------------| ---- |-------------------|
809| strategy  | [StrategyType](js-apis-data-cloudData.md#strategytype)    | 是   | 配置的策略类型。          |
810| param | Array&lt;[commonType.ValueType](js-apis-data-commonType.md#valuetype)&gt; | 否   | 策略参数。不填写默认为空,默认取消所有配置。 |
811
812**返回值:**
813
814| 类型                | 说明                      |
815| ------------------- | ------------------------- |
816| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
817
818**错误码:**
819
820以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
821
822| 错误码ID | 错误信息                                             |
823| -------- | ---------------------------------------------------- |
824| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
825| 202      | Permission verification failed, application which is not a system application uses system API.|
826| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
827| 801      | Capability not supported.|
828
829**示例:**
830
831```ts
832import { BusinessError } from '@kit.BasicServicesKit';
833
834cloudData.Config.setGlobalCloudStrategy(cloudData.StrategyType.NETWORK, [cloudData.NetWorkStrategy.WIFI]).then(() => {
835    console.info('Succeeded in setting the global cloud strategy');
836}).catch((err: BusinessError) => {
837    console.error(`Failed to set global cloud strategy. Code: ${err.code}, message: ${err.message}`);
838});
839```
840
841###  clear
842
843static clear(accountId: string, appActions: Record<string, ClearAction>,  callback: AsyncCallback&lt;void&gt;): void
844
845清除本地下载的云端数据,使用callback异步回调。
846
847**需要权限**:ohos.permission.CLOUDDATA_CONFIG
848
849**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
850
851**参数:**
852
853| 参数名     | 类型                                                | 必填 | 说明                             |
854| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
855| accountId  | string                                              | 是   | 具体打开的云账号ID。             |
856| appActions | Record<string, [ClearAction](#clearaction)>         | 是   | 要清除数据的应用信息及清除规则。 |
857| callback   | AsyncCallback&lt;void&gt;                           | 是   | 回调函数。                       |
858
859**错误码:**
860
861以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
862
863| 错误码ID | 错误信息                                             |
864| -------- | ---------------------------------------------------- |
865| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
866| 202      | Permission verification failed, application which is not a system application uses system API.|
867| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
868| 801      | Capability not supported.|
869
870**示例:**
871
872```ts
873import { BusinessError } from '@kit.BasicServicesKit';
874
875let account: string = "test_id";
876type dataType = Record<string, cloudData.ClearAction>
877let appActions: dataType = {
878  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
879  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
880};
881try {
882  cloudData.Config.clear(account, appActions, (err: BusinessError) => {
883    if (err === undefined) {
884      console.info('Succeeding in clearing cloud data');
885    } else {
886      console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
887    }
888  });
889} catch (e) {
890  let error = e as BusinessError;
891  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
892}
893```
894
895### clear
896
897static clear(accountId: string, appActions: Record<string, ClearAction>): Promise&lt;void&gt;
898
899清除本地下载的云端数据,使用Promise异步回调。
900
901**需要权限**:ohos.permission.CLOUDDATA_CONFIG
902
903**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
904
905**参数:**
906
907| 参数名     | 类型                                                | 必填 | 说明                             |
908| ---------- | --------------------------------------------------- | ---- | -------------------------------- |
909| accountId  | string                                              | 是   | 具体打开的云账号ID。             |
910| appActions | Record<string, [ClearAction](#clearaction)>         | 是   | 要清除数据的应用信息及清除规则。 |
911
912**返回值:**
913
914| 类型                | 说明                      |
915| ------------------- | ------------------------- |
916| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
917
918**错误码:**
919
920以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
921
922| 错误码ID | 错误信息                                             |
923| -------- | ---------------------------------------------------- |
924| 201      | Permission verification failed, usually the result returned by VerifyAccessToken.|
925| 202      | Permission verification failed, application which is not a system application uses system API.|
926| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
927| 801      | Capability not supported.|
928
929**示例:**
930
931```ts
932import { BusinessError } from '@kit.BasicServicesKit';
933
934let account: string = "test_id";
935type dataType = Record<string, cloudData.ClearAction>;
936let appActions: dataType = {
937  'test_bundleName1': cloudData.ClearAction.CLEAR_CLOUD_INFO,
938  'test_bundleName2': cloudData.ClearAction.CLEAR_CLOUD_DATA_AND_INFO
939};
940try {
941  cloudData.Config.clear(account, appActions).then(() => {
942    console.info('Succeeding in clearing cloud data');
943  }).catch((err: BusinessError) => {
944    console.error(`Failed to clear cloud data. Code: ${err.code}, message: ${err.message}`);
945  });
946} catch (e) {
947  let error = e as BusinessError;
948  console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
949}
950```
951
952## sharing<sup>11+</sup>
953
954提供端云共享的方法,包括发起共享、取消共享、退出共享、更改共享数据权限、查找共享参与者、确认邀请、更改已确认的邀请、查找共享资源。
955
956### Role<sup>11+</sup>
957
958端云共享参与者的角色。
959
960**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
961
962| 名称           | 值   | 说明                               |
963| --------------| ---- | ---------------------------------- |
964| ROLE_INVITER  | 0    | 端云共享邀请者。请使用枚举名称而非枚举值。 |
965| ROLE_INVITEE  | 1    | 端云共享被邀请者。请使用枚举名称而非枚举值。 |
966
967### State<sup>11+</sup>
968
969端云共享状态。
970
971**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
972
973| 名称           | 值   | 说明                               |
974| --------------| ---- | ---------------------------------- |
975| STATE_UNKNOWN    | 0    | 未知状态。请使用枚举名称而非枚举值。   |
976| STATE_ACCEPTED   | 1    | 端云共享已接受。请使用枚举名称而非枚举值。 |
977| STATE_REJECTED   | 2    | 端云共享被拒绝。请使用枚举名称而非枚举值。 |
978| STATE_SUSPENDED  | 3    | 端云共享被暂时挂起,未作处理。请使用枚举名称而非枚举值。 |
979| STATE_UNAVAILABLE<sup>12+</sup>   | 4    | 端云共享不可用。请使用枚举名称而非枚举值。 |
980
981### SharingCode<sup>11+</sup>
982
983端云共享错误码。
984
985**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
986
987| 名称           | 值   | 说明                               |
988| --------------| ---- | ---------------------------------- |
989| SUCCESS                 | 0    | 成功。请使用枚举名称而非枚举值。   |
990| REPEATED_REQUEST        | 1    | 重复邀请,表示当前参与者已被邀请。请使用枚举名称而非枚举值。 |
991| NOT_INVITER             | 2    | 非端云共享的邀请者,表示当前参与者不是端云共享的邀请者。请使用枚举名称而非枚举值。 |
992| NOT_INVITER_OR_INVITEE  | 3    | 非法参与者,表示当前参与者既不是共享的邀请者,也不是共享的被邀请者。请使用枚举名称而非枚举值。 |
993| OVER_QUOTA              | 4    | 端云共享次数达到上限,表示当前账号可共享的次数达到上限。请使用枚举名称而非枚举值。   |
994| TOO_MANY_PARTICIPANTS   | 5    | 端云共享参与者数量达到上限。请使用枚举名称而非枚举值。 |
995| INVALID_ARGS            | 6    | 无效的参数。请使用枚举名称而非枚举值。 |
996| NETWORK_ERROR           | 7    | 网络错误。请使用枚举名称而非枚举值。 |
997| CLOUD_DISABLED          | 8    | 云开关未打开。请使用枚举名称而非枚举值。   |
998| SERVER_ERROR            | 9    | 服务端发生错误。请使用枚举名称而非枚举值。 |
999| INNER_ERROR             | 10   | 系统发生内部错误。请使用枚举名称而非枚举值。 |
1000| INVALID_INVITATION      | 11   | 无效的邀请,表示当前邀请已失效或不存在。请使用枚举名称而非枚举值。 |
1001| RATE_LIMIT              | 12   | 速率限制,表示单次同步的数据量达到上限。请使用枚举名称而非枚举值。   |
1002| CUSTOM_ERROR            | 1000 | 定制错误,小于该枚举值的错误码用于定义系统内部的标准错误码,大于该枚举值的错误码用于使用者自定义错误码。请使用枚举名称而非枚举值。 |
1003
1004### Result&lt;T&gt;<sup>11+</sup>
1005
1006端云共享结果的返回值。
1007
1008**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1009
1010| 名称          | 类型                          | 必填  | 说明           |
1011| ----------- | --------------------------- | --- | ------------ |
1012| code        | number                      | 是   | 错误码。       |
1013| description | string                      | 否   | 错误码详细描述,默认为undefined。       |
1014| value       | T                           | 否   | 返回结果的值,具体类型由参数T指定,默认为undefined。 |
1015
1016### Privilege<sup>11+</sup>
1017
1018指定的端云共享数据的权限。
1019
1020**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1021
1022| 名称          | 类型                          | 必填  | 说明           |
1023| ----------- | --------------------------- | --- | ------------ |
1024| writable    | boolean              | 否   | 被共享者是否可修改共享的数据。true表示可修改,false表示不可修改,默认不可修改。   |
1025| readable    | boolean              | 否   | 被共享者是否可读取共享的数据。true表示可读取,false表示不可读取,默认不可读取。   |
1026| creatable   | boolean              | 否   | 被共享者是否可创建新的共享数据。true表示可创建,false表示不可创建,默认不可创建。  |
1027| deletable   | boolean              | 否   | 被共享者是否可删除共享的数据。true表示可删除,false表示不可删除,默认不可删除。  |
1028| shareable   | boolean              | 否   | 被共享者是否可将共享的数据再次共享给其他参与者。true表示可再次共享,false表示不可再次共享,默认不可再次共享。  |
1029
1030### Participant<sup>11+</sup>
1031
1032端云共享的参与者。
1033
1034**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1035
1036| 名称          | 类型                          | 必填  | 说明           |
1037| ----------- | --------------------------- | --- | ------------ |
1038| identity    | string                  | 是   | 参与者的ID。              |
1039| role        | [Role](#role11)           | 否   | 参与者的角色,为邀请者或被邀请者。默认为undefined。  |
1040| state       | [State](#state11)         | 否   | 共享的状态。默认为undefined。 |
1041| privilege   | [Privilege](#privilege11) | 否   | 指定的共享数据权限。默认为[Privilege](#privilege11)的默认值。 |
1042| attachInfo  | string                  | 否   | 附加信息,用于拓展额外的参与者信息。如用于参与者身份校验的校验码等,默认为空字符串。 |
1043
1044### allocResourceAndShare<sup>11+</sup>
1045
1046allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns?: Array&lt;string&gt;): Promise&lt;relationalStore.ResultSet&gt;
1047
1048根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集。如果指定了列字段,则返回的结果集中同时包含对应列的字段值,使用Promise异步回调。
1049
1050**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1051
1052**参数:**
1053
1054| 参数名    | 类型                            | 必填 | 说明                         |
1055| --------- | ------------------------------- | ---- | ---------------------------- |
1056| storeId      | string                        | 是   | 数据库名称。 |
1057| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1058| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1059| columns      | Array&lt;string&gt;           | 否   | 表示要查找的列字段名。默认为undefined,不返回列字段。 |
1060
1061**返回值:**
1062
1063| 类型                | 说明                      |
1064| ------------------- | ------------------------- |
1065| Promise&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt; | Promise对象,返回查询并共享的共享资源标识结果集。 |
1066
1067**错误码:**
1068
1069以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1070
1071| 错误码ID | 错误信息                                             |
1072| -------- | ---------------------------------------------------- |
1073| 202      | Permission verification failed, application which is not a system application uses system API.|
1074| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1075| 801      | Capability not supported.|
1076
1077**示例:**
1078
1079```ts
1080import { BusinessError } from '@kit.BasicServicesKit';
1081import { relationalStore } from '@kit.ArkData';
1082
1083let participants = new Array<cloudData.sharing.Participant>();
1084participants.push({
1085  identity: '000000000',
1086  role: cloudData.sharing.Role.ROLE_INVITER,
1087  state: cloudData.sharing.State.STATE_UNKNOWN,
1088  privilege: {
1089    writable: true,
1090    readable: true,
1091    creatable: false,
1092    deletable: false,
1093    shareable: false
1094  },
1095  attachInfo: ''
1096})
1097let sharingResource: string;
1098let predicates = new relationalStore.RdbPredicates('test_table');
1099predicates.equalTo('data', 'data_test');
1100cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data']).then((resultSet) => {
1101  if (!resultSet.goToFirstRow()) {
1102    console.error(`row error`);
1103    return;
1104  }
1105  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1106  console.info(`sharing resource: ${res}`);
1107  sharingResource = res;
1108}).catch((err: BusinessError) => {
1109  console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1110})
1111
1112```
1113
1114### allocResourceAndShare<sup>11+</sup>
1115
1116allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1117
1118根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集。并根据指定的列字段,返回的结果集中同时包含对应列的字段值,使用callback异步回调。
1119
1120**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1121
1122**参数:**
1123
1124| 参数名    | 类型                            | 必填 | 说明                         |
1125| --------- | ------------------------------- | ---- | ---------------------------- |
1126| storeId      | string                        | 是   | 数据库名称。 |
1127| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1128| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1129| columns      | Array&lt;string&gt;           | 是   | 表示要查找的列字段名。 |
1130| callback     | AsyncCallback&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt;  | 是  | 回调函数。 返回查询并共享的共享资源标识结果集。 |
1131
1132**错误码:**
1133
1134以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1135
1136| 错误码ID | 错误信息                                             |
1137| -------- | ---------------------------------------------------- |
1138| 202      | Permission verification failed, application which is not a system application uses system API.|
1139| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1140| 801      | Capability not supported.|
1141
1142**示例:**
1143
1144```ts
1145import { relationalStore } from '@kit.ArkData';
1146import { BusinessError } from '@kit.BasicServicesKit';
1147
1148let participants = new Array<cloudData.sharing.Participant>();
1149participants.push({
1150  identity: '000000000',
1151  role: cloudData.sharing.Role.ROLE_INVITER,
1152  state: cloudData.sharing.State.STATE_UNKNOWN,
1153  privilege: {
1154    writable: true,
1155    readable: true,
1156    creatable: false,
1157    deletable: false,
1158    shareable: false
1159  },
1160  attachInfo: ''
1161})
1162let sharingResource: string;
1163let predicates = new relationalStore.RdbPredicates('test_table');
1164predicates.equalTo('data', 'data_test');
1165cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, ['uuid', 'data'], (err: BusinessError, resultSet) => {
1166  if (err) {
1167    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1168    return;
1169  }
1170  if (!resultSet.goToFirstRow()) {
1171    console.error(`row error`);
1172    return;
1173  }
1174  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1175  console.info(`sharing resource: ${res}`);
1176  sharingResource = res;
1177})
1178
1179```
1180
1181### allocResourceAndShare<sup>11+</sup>
1182
1183allocResourceAndShare(storeId: string, predicates: relationalStore.RdbPredicates, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;relationalStore.ResultSet&gt;): void
1184
1185根据谓词条件匹配的数据申请共享资源标识并发起共享,返回已共享资源的结果集,使用callback异步回调。
1186
1187**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1188
1189**参数:**
1190
1191| 参数名    | 类型                            | 必填 | 说明                         |
1192| --------- | ------------------------------- | ---- | ---------------------------- |
1193| storeId      | string                        | 是   | 数据库名称。 |
1194| predicates   | [relationalStore.RdbPredicates](js-apis-data-relationalStore.md#rdbpredicates) | 是   | 表示查找共享资源标识的数据的谓词条件。 |
1195| participants | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1196| callback     | AsyncCallback&lt;[relationalStore.ResultSet](js-apis-data-relationalStore.md#resultset)&gt;  | 是   | 回调函数。返回查询并共享的共享资源标识结果集。 |
1197
1198**错误码:**
1199
1200以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1201
1202| 错误码ID | 错误信息                                             |
1203| -------- | ---------------------------------------------------- |
1204| 202      | Permission verification failed, application which is not a system application uses system API.|
1205| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1206| 801      | Capability not supported.|
1207
1208**示例:**
1209
1210```ts
1211import { relationalStore } from '@kit.ArkData';
1212import { BusinessError } from '@kit.BasicServicesKit';
1213
1214let participants = new Array<cloudData.sharing.Participant>();
1215participants.push({
1216  identity: '000000000',
1217  role: cloudData.sharing.Role.ROLE_INVITER,
1218  state: cloudData.sharing.State.STATE_UNKNOWN,
1219  privilege: {
1220    writable: true,
1221    readable: true,
1222    creatable: false,
1223    deletable: false,
1224    shareable: false
1225  },
1226  attachInfo: ''
1227})
1228let sharingResource: string;
1229let predicates = new relationalStore.RdbPredicates('test_table');
1230predicates.equalTo('data', 'data_test');
1231cloudData.sharing.allocResourceAndShare('storeName', predicates, participants, (err: BusinessError, resultSet) => {
1232  if (err) {
1233    console.error(`alloc resource and share failed, code is ${err.code},message is ${err.message}`);
1234    return;
1235  }
1236  if (!resultSet.goToFirstRow()) {
1237    console.error(`row error`);
1238    return;
1239  }
1240  const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
1241  console.info(`sharing resource: ${res}`);
1242  sharingResource = res;
1243})
1244
1245```
1246
1247### share<sup>11+</sup>
1248
1249share(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1250
1251根据指定的共享资源标识和共享参与者发起共享邀请,使用Promise异步回调。
1252
1253**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1254
1255**参数:**
1256
1257| 参数名    | 类型                            | 必填 | 说明                         |
1258| --------- | ------------------------------- | ---- | ---------------------------- |
1259| sharingResource   | string                                     | 是   | 端云共享数据的资源标识。 |
1260| participants      | Array&lt;[Participant](#participant11)&gt;   | 是   | 端云共享的参与者。 |
1261
1262**返回值:**
1263
1264| 类型                | 说明                      |
1265| ------------------- | ------------------------- |
1266| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回端云共享的结果。 |
1267
1268**错误码:**
1269
1270以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1271
1272| 错误码ID | 错误信息                                             |
1273| -------- | ---------------------------------------------------- |
1274| 202      | Permission verification failed, application which is not a system application uses system API.|
1275| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1276| 801      | Capability not supported.|
1277
1278**示例:**
1279
1280```ts
1281import { BusinessError } from '@kit.BasicServicesKit';
1282
1283let participants = new Array<cloudData.sharing.Participant>();
1284participants.push({
1285  identity: '000000000',
1286  role: cloudData.sharing.Role.ROLE_INVITER,
1287  state: cloudData.sharing.State.STATE_UNKNOWN,
1288  privilege: {
1289    writable: true,
1290    readable: true,
1291    creatable: false,
1292    deletable: false,
1293    shareable: false
1294  },
1295  attachInfo: ''
1296})
1297cloudData.sharing.share('sharing_resource_test', participants).then((result) => {
1298  console.info(`share success, result: ${result}`);
1299}).catch((err: BusinessError) => {
1300  console.error(`share failed, code is ${err.code},message is ${err.message}`);
1301})
1302
1303```
1304
1305### share<sup>11+</sup>
1306
1307share(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1308
1309根据指定的共享资源标识和共享参与者发起共享邀请,使用callback异步回调。
1310
1311**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1312
1313**参数:**
1314
1315| 参数名    | 类型                            | 必填 | 说明                         |
1316| --------- | ------------------------------- | ---- | ---------------------------- |
1317| sharingResource  | string                                     | 是   | 端云共享数据的资源标识。 |
1318| participants     | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1319| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回端云共享的结果。 |
1320
1321**错误码:**
1322
1323以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1324
1325| 错误码ID | 错误信息                                             |
1326| -------- | ---------------------------------------------------- |
1327| 202      | Permission verification failed, application which is not a system application uses system API.|
1328| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1329| 801      | Capability not supported.|
1330
1331**示例:**
1332
1333```ts
1334import { BusinessError } from '@kit.BasicServicesKit';
1335
1336let participants = new Array<cloudData.sharing.Participant>();
1337participants.push({
1338  identity: '000000000',
1339  role: cloudData.sharing.Role.ROLE_INVITER,
1340  state: cloudData.sharing.State.STATE_UNKNOWN,
1341  privilege: {
1342    writable: true,
1343    readable: true,
1344    creatable: false,
1345    deletable: false,
1346    shareable: false
1347  },
1348  attachInfo: ''
1349})
1350cloudData.sharing.share('sharing_resource_test', participants, ((err: BusinessError, result) => {
1351  if (err) {
1352    console.error(`share failed, code is ${err.code},message is ${err.message}`);
1353    return;
1354  }
1355  console.info(`share succeeded, result: ${result}`);
1356}))
1357
1358```
1359
1360### unshare<sup>11+</sup>
1361
1362unshare(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1363
1364根据指定的共享资源标识和共享参与者取消共享,使用Promise异步回调。
1365
1366**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1367
1368**参数:**
1369
1370| 参数名    | 类型                            | 必填 | 说明                         |
1371| --------- | ------------------------------- | ---- | ---------------------------- |
1372| sharingResource   | string                                     | 是   | 端云共享数据的资源标识。 |
1373| participants      | Array&lt;[Participant](#participant11)&gt; | 是   | 端云共享的参与者。 |
1374
1375**返回值:**
1376
1377| 类型                | 说明                      |
1378| ------------------- | ------------------------- |
1379| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回取消共享的结果。 |
1380
1381**错误码:**
1382
1383以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1384
1385| 错误码ID | 错误信息                                             |
1386| -------- | ---------------------------------------------------- |
1387| 202      | Permission verification failed, application which is not a system application uses system API.|
1388| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1389| 801      | Capability not supported.|
1390
1391**示例:**
1392
1393```ts
1394import { BusinessError } from '@kit.BasicServicesKit';
1395
1396let participants = new Array<cloudData.sharing.Participant>();
1397participants.push({
1398  identity: '000000000',
1399  role: cloudData.sharing.Role.ROLE_INVITER,
1400  state: cloudData.sharing.State.STATE_UNKNOWN,
1401  privilege: {
1402    writable: true,
1403    readable: true,
1404    creatable: false,
1405    deletable: false,
1406    shareable: false
1407  },
1408  attachInfo: ''
1409})
1410cloudData.sharing.unshare('sharing_resource_test', participants).then((result) => {
1411  console.info(`unshare succeeded, result: ${result}`);
1412}).catch((err: BusinessError) => {
1413  console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1414})
1415
1416```
1417
1418### unshare<sup>11+</sup>
1419
1420unshare(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1421
1422根据指定的共享资源标识和共享参与者取消共享,使用callback异步回调。
1423
1424**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1425
1426**参数:**
1427
1428| 参数名    | 类型                            | 必填 | 说明                         |
1429| --------- | ------------------------------- | ---- | ---------------------------- |
1430| sharingResource  | string                                     | 是   | 共享数据的资源标志。 |
1431| participants     | Array&lt;[Participant](#participant11)&gt; | 是   | 共享参与者。 |
1432| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回取消共享的结果。 |
1433
1434**错误码:**
1435
1436以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1437
1438| 错误码ID | 错误信息                                             |
1439| -------- | ---------------------------------------------------- |
1440| 202      | Permission verification failed, application which is not a system application uses system API.|
1441| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1442| 801      | Capability not supported.|
1443
1444**示例:**
1445
1446```ts
1447import { BusinessError } from '@kit.BasicServicesKit';
1448
1449let participants = new Array<cloudData.sharing.Participant>();
1450participants.push({
1451  identity: '000000000',
1452  role: cloudData.sharing.Role.ROLE_INVITER,
1453  state: cloudData.sharing.State.STATE_UNKNOWN,
1454  privilege: {
1455    writable: true,
1456    readable: true,
1457    creatable: false,
1458    deletable: false,
1459    shareable: false
1460  },
1461  attachInfo: ''
1462})
1463cloudData.sharing.unshare('sharing_resource_test', participants, ((err: BusinessError, result) => {
1464  if (err) {
1465    console.error(`unshare failed, code is ${err.code},message is ${err.message}`);
1466    return;
1467  }
1468  console.info(`unshare succeeded, result: ${result}`);
1469}))
1470
1471```
1472
1473### exit<sup>11+</sup>
1474
1475exit(sharingResource: string): Promise&lt;Result&lt;void&gt;&gt;
1476
1477根据指定的共享资源标识退出共享,使用Promise异步回调。
1478
1479**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1480
1481**参数:**
1482
1483| 参数名    | 类型                            | 必填 | 说明                         |
1484| --------- | ------------------------------- | ---- | ---------------------------- |
1485| sharingResource   | string       | 是   | 端云共享数据的资源标识。 |
1486
1487**返回值:**
1488
1489| 类型                | 说明                      |
1490| ------------------- | ------------------------- |
1491| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; | Promise对象,返回退出端云共享的结果。 |
1492
1493**错误码:**
1494
1495以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1496
1497| 错误码ID | 错误信息                                             |
1498| -------- | ---------------------------------------------------- |
1499| 202      | Permission verification failed, application which is not a system application uses system API.|
1500| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1501| 801      | Capability not supported.|
1502
1503**示例:**
1504
1505```ts
1506import { BusinessError } from '@kit.BasicServicesKit';
1507
1508cloudData.sharing.exit('sharing_resource_test').then((result) => {
1509  console.info(`exit share success, result: ${result}`);
1510}).catch((err: BusinessError) => {
1511  console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1512})
1513
1514```
1515
1516### exit<sup>11+</sup>
1517
1518exit(sharingResource: string, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void
1519
1520根据指定的共享资源标识退出共享,使用callback异步回调。
1521
1522**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1523
1524**参数:**
1525
1526| 参数名    | 类型                            | 必填 | 说明                         |
1527| --------- | ------------------------------- | ---- | ---------------------------- |
1528| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1529| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt;  | 是   | 回调函数。返回退出共享的结果。 |
1530
1531**错误码:**
1532
1533以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1534
1535| 错误码ID | 错误信息                                             |
1536| -------- | ---------------------------------------------------- |
1537| 202      | Permission verification failed, application which is not a system application uses system API.|
1538| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1539| 801      | Capability not supported.|
1540
1541**示例:**
1542
1543```ts
1544import { BusinessError } from '@kit.BasicServicesKit';
1545
1546cloudData.sharing.exit('sharing_resource_test', ((err: BusinessError, result) => {
1547  if (err) {
1548    console.error(`exit share failed, code is ${err.code},message is ${err.message}`);
1549    return;
1550  }
1551  console.info(`exit share succeeded, result: ${result}`);
1552}))
1553
1554```
1555
1556### changePrivilege<sup>11+</sup>
1557
1558changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;): Promise&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;
1559
1560根据指定的共享资源标识更改共享参与者对共享数据的操作权限,使用Promise异步回调。
1561
1562**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1563
1564**参数:**
1565
1566| 参数名    | 类型                            | 必填 | 说明                         |
1567| --------- | ------------------------------- | ---- | ---------------------------- |
1568| sharingResource   | string                                    | 是   | 端云共享数据的资源标识。 |
1569| participants      | Array&lt;[Participant](#participant11)&gt;  | 是   | 端云共享的参与者。 |
1570
1571**返回值:**
1572
1573| 类型                | 说明                      |
1574| ------------------- | ------------------------- |
1575| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt; | Promise对象,返回更改共享参与者权限的结果。 |
1576
1577**错误码:**
1578
1579以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1580
1581| 错误码ID | 错误信息                                             |
1582| -------- | ---------------------------------------------------- |
1583| 202      | Permission verification failed, application which is not a system application uses system API.|
1584| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1585| 801      | Capability not supported.|
1586
1587**示例:**
1588
1589```ts
1590import { BusinessError } from '@kit.BasicServicesKit';
1591
1592let participants = new Array<cloudData.sharing.Participant>();
1593participants.push({
1594  identity: '000000000',
1595  role: cloudData.sharing.Role.ROLE_INVITER,
1596  state: cloudData.sharing.State.STATE_UNKNOWN,
1597  privilege: {
1598    writable: true,
1599    readable: true,
1600    creatable: false,
1601    deletable: false,
1602    shareable: false
1603  },
1604  attachInfo: ''
1605})
1606
1607cloudData.sharing.changePrivilege('sharing_resource_test', participants).then((result) => {
1608  console.info(`change privilege succeeded, result: ${result}`);
1609}).catch((err: BusinessError) => {
1610  console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1611})
1612
1613```
1614
1615### changePrivilege<sup>11+</sup>
1616
1617changePrivilege(sharingResource: string, participants: Array&lt;Participant&gt;, callback: AsyncCallback&lt;Result&lt;Array&lt;Result&lt;Participant&gt;&gt;&gt;&gt;): void
1618
1619根据指定的共享资源标识更改共享参与者对共享数据的操作权限,使用callback异步回调。
1620
1621**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1622
1623**参数:**
1624
1625| 参数名    | 类型                            | 必填 | 说明                         |
1626| --------- | ------------------------------- | ---- | ---------------------------- |
1627| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1628| participants     | Array&lt;[Participant](#participant11)&gt;  | 是   | 端云共享的参与者。 |
1629| callback         | callback: AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Result](#resultt11)&lt;[Participant](#participant11)&gt;&gt;&gt;&gt;  | 是   | 回调函数。返回更改权限的结果。 |
1630
1631**错误码:**
1632
1633以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1634
1635| 错误码ID | 错误信息                                             |
1636| -------- | ---------------------------------------------------- |
1637| 202      | Permission verification failed, application which is not a system application uses system API.|
1638| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1639| 801      | Capability not supported.|
1640
1641**示例:**
1642
1643```ts
1644import { BusinessError } from '@kit.BasicServicesKit';
1645
1646let participants = new Array<cloudData.sharing.Participant>();
1647participants.push({
1648  identity: '000000000',
1649  role: cloudData.sharing.Role.ROLE_INVITER,
1650  state: cloudData.sharing.State.STATE_UNKNOWN,
1651  privilege: {
1652    writable: true,
1653    readable: true,
1654    creatable: false,
1655    deletable: false,
1656    shareable: false
1657  },
1658  attachInfo: ''
1659})
1660
1661cloudData.sharing.changePrivilege('sharing_resource_test', participants, ((err: BusinessError, result) => {
1662  if (err) {
1663    console.error(`change privilege failed, code is ${err.code},message is ${err.message}`);
1664    return;
1665  }
1666  console.info(`change privilege succeeded, result: ${result}`);
1667}))
1668
1669```
1670
1671### queryParticipants<sup>11+</sup>
1672
1673queryParticipants(sharingResource: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1674
1675根据指定的共享资源标识查询当前共享的参与者,使用Promise异步回调。
1676
1677**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1678
1679**参数:**
1680
1681| 参数名    | 类型                            | 必填 | 说明                         |
1682| --------- | ------------------------------- | ---- | ---------------------------- |
1683| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1684
1685**返回值:**
1686
1687| 类型                | 说明                      |
1688| ------------------- | ------------------------- |
1689| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise对象,返回查询共享参与者的结果。 |
1690
1691**错误码:**
1692
1693以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1694
1695| 错误码ID | 错误信息                                             |
1696| -------- | ---------------------------------------------------- |
1697| 202      | Permission verification failed, application which is not a system application uses system API.|
1698| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1699| 801      | Capability not supported.|
1700
1701**示例:**
1702
1703```ts
1704import { BusinessError } from '@kit.BasicServicesKit';
1705
1706cloudData.sharing.queryParticipants('sharing_resource_test').then((result) => {
1707  console.info(`query participants succeeded, result: ${result}`);
1708}).catch((err: BusinessError) => {
1709  console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1710})
1711
1712```
1713
1714### queryParticipants<sup>11+</sup>
1715
1716queryParticipants(sharingResource: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1717
1718根据指定的共享资源标识查询当前共享的参与者,使用callback异步回调。
1719
1720**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1721
1722**参数:**
1723
1724| 参数名    | 类型                            | 必填 | 说明                         |
1725| --------- | ------------------------------- | ---- | ---------------------------- |
1726| sharingResource  | string                | 是   | 端云共享数据的资源标识。 |
1727| callback         | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt;  | 是   | 回调函数。返回查找共享参与者的结果。 |
1728
1729**错误码:**
1730
1731以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1732
1733| 错误码ID | 错误信息                                             |
1734| -------- | ---------------------------------------------------- |
1735| 202      | Permission verification failed, application which is not a system application uses system API.|
1736| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1737| 801      | Capability not supported.|
1738
1739**示例:**
1740
1741```ts
1742import { BusinessError } from '@kit.BasicServicesKit';
1743
1744cloudData.sharing.queryParticipants('sharing_resource_test', ((err: BusinessError, result) => {
1745  if (err) {
1746    console.error(`query participants failed, code is ${err.code},message is ${err.message}`);
1747    return;
1748  }
1749  console.info(`query participants succeeded, result: ${result}`);
1750}))
1751
1752```
1753
1754### queryParticipantsByInvitation<sup>11+</sup>
1755
1756queryParticipantsByInvitation(invitationCode: string): Promise&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;
1757
1758根据指定的共享邀请码查询当前共享的参与者,使用Promise异步回调。
1759
1760**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1761
1762**参数:**
1763
1764| 参数名    | 类型                            | 必填 | 说明                         |
1765| --------- | ------------------------------- | ---- | ---------------------------- |
1766| invitationCode   | string                 | 是   | 端云共享的邀请码。 |
1767
1768**返回值:**
1769
1770| 类型                | 说明                      |
1771| ------------------- | ------------------------- |
1772| Promise&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | Promise对象,返回查找共享参与者的结果。|
1773
1774**错误码:**
1775
1776以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1777
1778| 错误码ID | 错误信息                                             |
1779| -------- | ---------------------------------------------------- |
1780| 202      | Permission verification failed, application which is not a system application uses system API.|
1781| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1782| 801      | Capability not supported.|
1783
1784**示例:**
1785
1786```ts
1787import { BusinessError } from '@kit.BasicServicesKit';
1788
1789cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test').then((result) => {
1790  console.info(`query participants by invitation succeeded, result: ${result}`);
1791}).catch((err: BusinessError) => {
1792  console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1793})
1794
1795```
1796
1797### queryParticipantsByInvitation<sup>11+</sup>
1798
1799queryParticipantsByInvitation(invitationCode: string, callback: AsyncCallback&lt;Result&lt;Array&lt;Participant&gt;&gt;&gt;): void
1800
1801根据指定的共享邀请码查询当前共享的参与者,使用callback异步回调。
1802
1803**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1804
1805**参数:**
1806
1807| 参数名    | 类型                            | 必填 | 说明                         |
1808| --------- | ------------------------------- | ---- | ---------------------------- |
1809| invitationCode  | string                | 是   | 端云共享的邀请码。 |
1810| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;Array&lt;[Participant](#participant11)&gt;&gt;&gt; | 是   | 回调函数。返回查找共享参与者的结果。 |
1811
1812**错误码:**
1813
1814以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1815
1816| 错误码ID | 错误信息                                             |
1817| -------- | ---------------------------------------------------- |
1818| 202      | Permission verification failed, application which is not a system application uses system API.|
1819| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1820| 801      | Capability not supported.|
1821
1822**示例:**
1823
1824```ts
1825import { BusinessError } from '@kit.BasicServicesKit';
1826
1827cloudData.sharing.queryParticipantsByInvitation('sharing_invitation_code_test', ((err: BusinessError, result) => {
1828  if (err) {
1829    console.error(`query participants by invitation failed, code is ${err.code},message is ${err.message}`);
1830    return;
1831  }
1832  console.info(`query participants by invitation succeeded, result: ${result}`);
1833}))
1834
1835```
1836
1837### confirmInvitation<sup>11+</sup>
1838
1839confirmInvitation(invitationCode: string, state: State): Promise&lt;Result&lt;string&gt;&gt;
1840
1841被邀请者根据共享邀请码确认当前邀请,并获取当前邀请的共享资源标识,使用Promise异步回调。
1842
1843**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1844
1845**参数:**
1846
1847| 参数名    | 类型                            | 必填 | 说明                         |
1848| --------- | ------------------------------- | ---- | ---------------------------- |
1849| invitationCode   | string                 | 是   | 端云共享的邀请码。 |
1850| state            | [State](#state11)        | 是   | 确认邀请的状态。 |
1851
1852**返回值:**
1853
1854| 类型                | 说明                      |
1855| ------------------- | ------------------------- |
1856| Promise&lt;[Result](#resultt11)&lt;string&gt;&gt; | Promise对象,返回确认共享邀请的结果。 |
1857
1858**错误码:**
1859
1860以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1861
1862| 错误码ID | 错误信息                                             |
1863| -------- | ---------------------------------------------------- |
1864| 202      | Permission verification failed, application which is not a system application uses system API.|
1865| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1866| 801      | Capability not supported.|
1867
1868**示例:**
1869
1870```ts
1871import { BusinessError } from '@kit.BasicServicesKit';
1872
1873let shareResource: string | undefined;
1874cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED).then((result: cloudData.sharing.Result<string>) => {
1875  console.info(`confirm invitation succeeded, result: ${result}`);
1876  shareResource = result.value;
1877}).catch((err: BusinessError) => {
1878  console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1879})
1880
1881```
1882
1883### confirmInvitation<sup>11+</sup>
1884
1885confirmInvitation(invitationCode: string, state: State, callback: AsyncCallback&lt;Result&lt;string&gt;&gt;): void
1886
1887被邀请者根据共享邀请码确认当前邀请,并获取当前邀请的共享资源标识,使用callback异步回调。
1888
1889**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1890
1891**参数:**
1892
1893| 参数名    | 类型                            | 必填 | 说明                         |
1894| --------- | ------------------------------- | ---- | ---------------------------- |
1895| invitationCode  | string                | 是   | 端云共享的邀请码。 |
1896| state           | [State](#state11)       | 是   | 确认邀请的状态。 |
1897| callback        | AsyncCallback&lt;[Result](#resultt11)&lt;string&gt;&gt; | 是   | 回调函数。返回确认邀请的结果。 |
1898
1899**错误码:**
1900
1901以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1902
1903| 错误码ID | 错误信息                                             |
1904| -------- | ---------------------------------------------------- |
1905| 202      | Permission verification failed, application which is not a system application uses system API.|
1906| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1907| 801      | Capability not supported.|
1908
1909**示例:**
1910
1911```ts
1912import { BusinessError } from '@kit.BasicServicesKit';
1913
1914let shareResource: string;
1915cloudData.sharing.confirmInvitation('sharing_invitation_code_test', cloudData.sharing.State.STATE_ACCEPTED, ((err: BusinessError, result) => {
1916  if (err) {
1917    console.error(`confirm invitation failed, code is ${err.code},message is ${err.message}`);
1918    return;
1919  }
1920  console.info(`confirm invitation succeeded, result: ${result}`);
1921  shareResource = result.value;
1922}))
1923
1924```
1925
1926### changeConfirmation<sup>11+</sup>
1927
1928changeConfirmation(sharingResource: string, state: State): Promise&lt;Result&lt;void&gt;&gt;
1929
1930根据共享资源标识更改共享邀请的状态,使用Promise异步回调。
1931
1932**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1933
1934**参数:**
1935
1936| 参数名    | 类型                            | 必填 | 说明                         |
1937| --------- | ------------------------------- | ---- | ---------------------------- |
1938| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1939| state             | [State](#state11)        | 是   | 更改邀请的状态。 |
1940
1941**返回值:**
1942
1943| 类型                | 说明                      |
1944| ------------------- | ------------------------- |
1945| Promise&lt;[Result](#resultt11)&lt;void&gt;&gt; |  Promise对象,返回更改共享邀请状态的结果。 |
1946
1947**错误码:**
1948
1949以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1950
1951| 错误码ID | 错误信息                                             |
1952| -------- | ---------------------------------------------------- |
1953| 202      | Permission verification failed, application which is not a system application uses system API.|
1954| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1955| 801      | Capability not supported.|
1956
1957**示例:**
1958
1959```ts
1960import { BusinessError } from '@kit.BasicServicesKit';
1961
1962cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED).then((result) => {
1963  console.info(`change confirmation succeeded, result: ${result}`);
1964}).catch((err: BusinessError) => {
1965  console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
1966})
1967
1968```
1969
1970### changeConfirmation<sup>11+</sup>
1971
1972changeConfirmation(sharingResource: string, state: State, callback: AsyncCallback&lt;Result&lt;void&gt;&gt;): void;
1973
1974根据共享资源标识更改共享邀请的状态,使用callback异步回调。
1975
1976**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Client
1977
1978**参数:**
1979
1980| 参数名    | 类型                            | 必填 | 说明                         |
1981| --------- | ------------------------------- | ---- | ---------------------------- |
1982| sharingResource   | string                 | 是   | 端云共享数据的资源标识。 |
1983| state             | [State](#state11)        | 是   | 更改邀请的状态。 |
1984| callback          | AsyncCallback&lt;[Result](#resultt11)&lt;void&gt;&gt; | 是   | 回调函数。返回更改邀请状态的结果。 |
1985
1986**错误码:**
1987
1988以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)。
1989
1990| 错误码ID | 错误信息                                             |
1991| -------- | ---------------------------------------------------- |
1992| 202      | Permission verification failed, application which is not a system application uses system API.|
1993| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
1994| 801      | Capability not supported.|
1995
1996**示例:**
1997
1998```ts
1999import { BusinessError } from '@kit.BasicServicesKit';
2000
2001cloudData.sharing.changeConfirmation('sharing_resource_test', cloudData.sharing.State.STATE_REJECTED, ((err: BusinessError, result) => {
2002  if (err) {
2003    console.error(`change confirmation failed, code is ${err.code},message is ${err.message}`);
2004    return;
2005  }
2006  console.info(`change confirmation succeeded, result: ${result}`);
2007}))
2008
2009```
2010<!--no_check-->
2011