• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.unifiedDataChannel (Unified Data Channel)
2
3As a part of the Unified Data Management Framework (UDMF), the **unifiedDataChannel** module provides unified data channels and standard data access interfaces for many-to-many data sharing across applications. It also provides definitions for uniform data types, such as text and image, to streamline data interaction between different applications and minimize the workload of data type adaptation.
4
5> **NOTE**
6>
7> 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.
8
9## Modules to Import
10
11```ts
12import { unifiedDataChannel } from '@kit.ArkData';
13```
14
15## ShareOptions<sup>12+</sup>
16
17Enumerates the options for using **UnifiedData** in a device.
18
19**Atomic service API**: This API can be used in atomic services since API version 12.
20
21**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
22
23| Name         | Value| Description               |
24|-------------|---|-------------------|
25| IN_APP       | 0 | **UnifiedData** can be used only in the same application of a device.|
26| CROSS_APP | 1 | **UnifiedData** can be used across applications of a device.|
27
28## GetDelayData<sup>12+</sup>
29
30type GetDelayData = (type: string) => UnifiedData
31
32A type that defines a function used to obtain a deferred **UnifiedData** object. Currently, it can be used only in the pasteboard application of the same device.
33
34**Atomic service API**: This API can be used in atomic services since API version 12.
35
36**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
37
38**Parameters**
39
40| Name| Type| Mandatory| Description|
41| -------- | -------- | -------- | -------- |
42| type | string | Yes| Identifier of the deferred encapsulation.|
43
44**Return value**
45
46| Type                                    | Description                     |
47| ---------------------------------------- |-------------------------|
48| [UnifiedData](#unifieddata) | **UnifiedData** object.|
49
50**Example**
51
52```ts
53import { uniformTypeDescriptor } from '@kit.ArkData';
54
55let getDelayData: unifiedDataChannel.GetDelayData = ((type: string) => {
56  if (type == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
57    let text = new unifiedDataChannel.Text();
58    text.details = {
59      Key: 'textKey',
60      Value: 'textValue',
61    };
62    let textData = new unifiedDataChannel.UnifiedData(text);
63    return textData;
64  }
65  return new unifiedDataChannel.UnifiedData();
66});
67```
68
69## ValueType<sup>12+</sup>
70
71type ValueType = number | string | boolean | image.PixelMap | Want | ArrayBuffer | object | null | undefined
72
73Enumerates the data field types allowed in a unified data record.
74
75**Atomic service API**: This API can be used in atomic services since API version 12.
76
77**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
78
79| Type| Description|
80| -------- | -------- |
81| number | Number.|
82| string | String.|
83| boolean | Boolean.|
84| image.PixelMap | [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7).|
85| Want | [Want](../apis-ability-kit/js-apis-app-ability-want.md).|
86| ArrayBuffer | ArrayBuffer.|
87| object | Object.|
88| null | Null.|
89| undefined | Undefined.|
90
91## UnifiedDataProperties<sup>12+</sup>
92
93Defines the properties of the data records in the unified data object, including the timestamp, tag, pasting range, and additional data.
94
95**Atomic service API**: This API can be used in atomic services since API version 12.
96
97**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
98
99| Name| Type| Read-Only| Optional| Description|
100| -------- | -------- | -------- | -------- | -------- |
101| extras<sup>12+</sup> | Record<string, object> | No| Yes| Object of the dictionary type used to set other properties. The default value is an empty dictionary object.|
102| tag<sup>12+</sup> | string | No| Yes| Customized tag. The default value is an empty string.|
103| timestamp<sup>12+</sup> | Date | Yes| Yes| Timestamp when [UnifiedData](#unifieddata) is generated. The default value is January 1, 1970 (UTC).|
104| shareOptions<sup>12+</sup> | [ShareOptions](#shareoptions12) | No| Yes| Range, in which [UnifiedData](#unifieddata) can be used. The default value is **CROSS_APP**.|
105| getDelayData<sup>12+</sup> | [GetDelayData](#getdelaydata12) | No| Yes| Callback for obtaining the deferred data. Currently, it can be used only in the pasteboard application of the same device. The default value is **undefined**.|
106
107**Example**
108
109```ts
110import { uniformTypeDescriptor } from '@kit.ArkData';
111
112let properties = new unifiedDataChannel.UnifiedDataProperties();
113properties.extras = {
114  key: {
115    title: 'MyTitle',
116    content: 'MyContent'
117  }
118};
119properties.tag = "this is tag of properties";
120properties.shareOptions = unifiedDataChannel.ShareOptions.CROSS_APP;
121properties.getDelayData = ((type: string) => {
122  if (type == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
123    let text = new unifiedDataChannel.Text();
124    text.details = {
125      Key: 'textKey',
126      Value: 'textValue',
127    };
128    let textData = new unifiedDataChannel.UnifiedData(text);
129    return textData;
130  }
131  return new unifiedDataChannel.UnifiedData();
132});
133```
134
135## UnifiedData
136
137Provides APIs for encapsulating a set of data records.
138
139**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
140
141### Properties
142
143| Name| Type| Read-Only| Optional| Description                                                                                             |
144| -------- | -------- | -------- | -------- |-------------------------------------------------------------------------------------------------|
145| properties<sup>12+</sup> | [UnifiedDataProperties](#unifieddataproperties12) | No| No| Properties of all the data records in a unified data object, including the timestamp, tag, application range, and additional data.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
146
147### constructor<sup>12+</sup>
148
149constructor()
150
151A constructor used to create a **UnifiedData** object.
152
153**Atomic service API**: This API can be used in atomic services since API version 12.
154
155**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
156
157**Example**
158
159```ts
160let unifiedData = new unifiedDataChannel.UnifiedData();
161```
162
163### constructor
164
165constructor(record: UnifiedRecord)
166
167A constructor used to create a **UnifiedData** object with a data record.
168
169**Atomic service API**: This API can be used in atomic services since API version 11.
170
171**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
172
173**Parameters**
174
175| Name| Type                           | Mandatory| Description                                     |
176| ------ | ------------------------------- | ---- |-----------------------------------------|
177| record | [UnifiedRecord](#unifiedrecord) | Yes  | Data record in the **UnifiedData** object. It is a **UnifiedRecord** object or its child class object.|
178
179**Error codes**
180
181For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
182
183| **ID**| **Error Message**                               |
184| ------------ | ------------------------------------------- |
185| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
186
187**Example**
188
189```ts
190let text = new unifiedDataChannel.PlainText();
191text.textContent = 'this is textContent of text';
192let unifiedData = new unifiedDataChannel.UnifiedData(text);
193```
194
195### addRecord
196
197addRecord(record: UnifiedRecord): void
198
199Adds a data record to this **UnifiedRecord** object.
200
201**Atomic service API**: This API can be used in atomic services since API version 11.
202
203**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
204
205**Parameters**
206
207| Name| Type                           | Mandatory| Description                                         |
208| ------ | ------------------------------- | ---- |---------------------------------------------|
209| record | [UnifiedRecord](#unifiedrecord) | Yes  | Data record to add. It is a **UnifiedRecord** child class object.|
210
211**Error codes**
212
213For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
214
215| **ID**| **Error Message**                               |
216| ------------ | ------------------------------------------- |
217| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
218
219**Example**
220
221```ts
222let text1 = new unifiedDataChannel.PlainText();
223text1.textContent = 'this is textContent of text1';
224let unifiedData = new unifiedDataChannel.UnifiedData(text1);
225
226let text2 = new unifiedDataChannel.PlainText();
227text2.textContent = 'this is textContent of text2';
228unifiedData.addRecord(text2);
229```
230
231### getRecords
232
233getRecords(): Array\<UnifiedRecord\>
234
235Obtains all data records from this **UnifiedData** object. The data obtained is of the **UnifiedRecord** type. Before using the data, you need to use [getType](#gettype) to obtain the data type and convert the data type to a child class.
236
237**Atomic service API**: This API can be used in atomic services since API version 11.
238
239**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
240
241**Return value**
242
243| Type                                    | Description                     |
244| ---------------------------------------- |-------------------------|
245| Array\<[UnifiedRecord](#unifiedrecord)\> | Records in the **UnifiedData** object obtained.|
246
247**Example**
248
249```ts
250import { uniformTypeDescriptor } from '@kit.ArkData';
251
252let text = new unifiedDataChannel.PlainText();
253text.textContent = 'this is textContent of text';
254let unifiedData = new unifiedDataChannel.UnifiedData(text);
255
256let link = new unifiedDataChannel.Hyperlink();
257link.url = 'www.XXX.com';
258unifiedData.addRecord(link);
259
260let records = unifiedData.getRecords();
261for (let i = 0; i < records.length; i++) {
262  let record = records[i];
263  if (record.getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
264    let plainText = record as unifiedDataChannel.PlainText;
265    console.info(`textContent: ${plainText.textContent}`);
266  } else if (record.getType() == uniformTypeDescriptor.UniformDataType.HYPERLINK) {
267    let hyperlink = record as unifiedDataChannel.Hyperlink;
268    console.info(`linkUrl: ${hyperlink.url}`);
269  }
270}
271```
272
273### hasType<sup>12+</sup>
274
275hasType(type: string): boolean
276
277Checks whether this **UnifiedData** object has the specified data type.
278
279**Atomic service API**: This API can be used in atomic services since API version 12.
280
281**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
282
283| Name| Type                           | Mandatory| Description                                         |
284| ------ | ------------------------------- | ---- |---------------------------------------------|
285| type | string | Yes  | Data type to check. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).|
286
287**Return value**
288
289| Type                                    | Description                     |
290| ---------------------------------------- |-------------------------|
291| boolean | Returns **true** if the specified data type exists; returns **false** otherwise.|
292
293**Error codes**
294
295For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
296
297| **ID**| **Error Message**                               |
298| ------------ | ------------------------------------------- |
299| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
300
301**Example**
302
303```ts
304import { uniformTypeDescriptor } from '@kit.ArkData';
305
306let text = new unifiedDataChannel.PlainText();
307text.textContent = 'this is textContent of text';
308let unifiedData = new unifiedDataChannel.UnifiedData(text);
309
310let link = new unifiedDataChannel.Hyperlink();
311link.url = 'www.XXX.com';
312unifiedData.addRecord(link);
313
314let hasPlainText = unifiedData.hasType(uniformTypeDescriptor.UniformDataType.PLAIN_TEXT);
315let hasLink = unifiedData.hasType(uniformTypeDescriptor.UniformDataType.HYPERLINK);
316```
317
318### getTypes<sup>12+</sup>
319
320getTypes(): Array\<string\>
321
322Obtains the types of all data records in this **UnifiedData** object.
323
324**Atomic service API**: This API can be used in atomic services since API version 12.
325
326**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
327
328**Return value**
329
330| Type                                    | Description                     |
331| ---------------------------------------- |-------------------------|
332| Array\<string\> | Array of the [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype) types obtained.|
333
334**Example**
335
336```ts
337let text = new unifiedDataChannel.PlainText();
338text.textContent = 'this is textContent of text';
339let unifiedData = new unifiedDataChannel.UnifiedData(text);
340
341let link = new unifiedDataChannel.Hyperlink();
342link.url = 'www.XXX.com';
343unifiedData.addRecord(link);
344
345let types = unifiedData.getTypes();
346```
347
348## Summary
349
350Represents the abstract of a uniform data object, including the data type and size.
351
352**Atomic service API**: This API can be used in atomic services since API version 11.
353
354**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
355
356| Name| Type| Read-Only| Optional| Description|
357| -------- | -------- | -------- | -------- | -------- |
358| summary   | Record<string, number> | No| No| Dictionary type object, where the key indicates the data type (see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype)), and the value indicates the total size (in bytes) of this type of records in the unified data object.|
359| totalSize | number | No| No| Total size of all the records in the **UnifiedData** object, in bytes.|
360
361## UnifiedRecord
362
363An abstract definition of the data content supported by the UDMF. A **UnifiedRecord** object contains one or more data records, for example, a text record, an image record, or an HTML record.
364
365### constructor<sup>12+</sup>
366
367constructor()
368
369A constructor used to create a **UnfiedRecord** object.
370
371**Atomic service API**: This API can be used in atomic services since API version 12.
372
373**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
374
375**Example**
376
377```ts
378let unifiedRecord = new unifiedDataChannel.UnifiedRecord();
379```
380
381### constructor<sup>12+</sup>
382
383constructor(type: string, value: ValueType)
384
385A constructor used to create a data record with the specified type and value.<br>If **value** is of the [image.PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) type, **type** must be the value of **OPENHARMONY_PIXEL_MAP** in [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).<br>If **value** is of the [Want](../apis-ability-kit/js-apis-app-ability-want.md) type, **type** must be the value of **OPENHARMONY_WANT** in [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).
386
387**Atomic service API**: This API can be used in atomic services since API version 12.
388
389**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
390
391**Parameters**
392
393| Name| Type                           | Mandatory| Description                                     |
394| ------ | ------------------------------- | ---- |-----------------------------------------|
395| type | string | Yes  | Type of the data record to create.|
396| value | [ValueType](#valuetype12) | Yes  | Value of the data record to create.|
397
398**Error codes**
399
400For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
401
402| **ID**| **Error Message**                               |
403| ------------ | ------------------------------------------- |
404| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types; 3. Parameter verification failed.  |
405
406**Example**
407
408```ts
409import { image } from '@kit.ImageKit';
410import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
411import { Want } from '@kit.AbilityKit';
412
413let text = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.PLAIN_TEXT, 'this is value of text');
414let link = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.HYPERLINK, 'www.XXX.com');
415let object: Want = {
416  bundleName: 'com.example.myapplication',
417  abilityName: 'entryAbility',
418};
419let wantRecord = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_WANT, object);
420
421const color = new ArrayBuffer(96);
422let opts: image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
423let pixelMap = image.createPixelMapSync(color, opts);
424let pixelMapRecord = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_PIXEL_MAP, pixelMap);
425
426let hyperlinkDetails : Record<string, string> = {
427  'attr1': 'value1',
428  'attr2': 'value2',
429}
430let hyperlink : uniformDataStruct.Hyperlink = {
431  uniformDataType:'general.hyperlink',
432  url : 'www.XXX.com',
433  description : 'This is the description of this hyperlink',
434  details : hyperlinkDetails,
435}
436let hyperlinkRecord = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.HYPERLINK, hyperlink);
437```
438
439### getType
440
441getType(): string
442
443Obtains the type of this **UnfiedRecord**. The data obtained by [getRecords](#getrecords) from the **UnifiedData** object is a **UnifiedRecord** object. You need to use this API to obtain the specific type of the record, convert the **UnifiedRecord** object to its child class, and call the child class interfaces.
444
445**Atomic service API**: This API can be used in atomic services since API version 11.
446
447**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
448
449**Return value**
450
451| Type  | Description                                                  |
452| ------ |------------------------------------------------------|
453| string | Data type obtained. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).|
454
455**Example**
456
457```ts
458import { uniformTypeDescriptor } from '@kit.ArkData';
459
460let text = new unifiedDataChannel.PlainText();
461text.textContent = 'this is textContent of text';
462let unifiedData = new unifiedDataChannel.UnifiedData(text);
463
464let records = unifiedData.getRecords();
465if (records[0].getType() == uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
466  let plainText = records[0] as unifiedDataChannel.PlainText;
467  console.info(`textContent: ${plainText.textContent}`);
468}
469```
470
471### getValue<sup>12+</sup>
472
473getValue(): ValueType
474
475Obtains the value of this data record.
476
477**Atomic service API**: This API can be used in atomic services since API version 12.
478
479**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
480
481**Return value**
482
483| Type  | Description                                                  |
484| ------ |------------------------------------------------------|
485| [ValueType](#valuetype12) | Value obtained.|
486
487**Example**
488
489```ts
490import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
491
492let text = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.PLAIN_TEXT, 'this is value of text');
493let value = text.getValue();
494
495let hyperlinkDetails : Record<string, string> = {
496  'attr1': 'value1',
497  'attr2': 'value2',
498}
499let hyperlink : uniformDataStruct.Hyperlink = {
500  uniformDataType:'general.hyperlink',
501  url : 'www.XXX.com',
502  description : 'This is the description of this hyperlink',
503  details : hyperlinkDetails,
504}
505let hyperlinkRecord = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.HYPERLINK, hyperlink);
506let hyperlinkValue = hyperlinkRecord.getValue();
507```
508
509### addEntry<sup>15+</sup>
510
511addEntry(type: string, value: ValueType): void
512
513Adds data to the current data record.
514
515**Atomic service API**: This API can be used in atomic services since API version 15.
516
517**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
518
519**Parameters**
520
521| Name| Type                           | Mandatory| Description                                     |
522| ------ | ------------------------------- | ---- |-----------------------------------------|
523| type | string | Yes  | Type of the data to add. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).|
524| value | [ValueType](#valuetype12) | Yes  | Value of the data to add.|
525
526**Error codes**
527
528For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
529
530| **ID**| **Error Message**                               |
531| ------------ | ------------------------------------------- |
532| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
533
534**Example**
535
536```ts
537import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
538
539let fileUriDetails : Record<string, string> = {
540  'attr1': 'value1',
541  'attr2': 'value2',
542}
543let fileUri : uniformDataStruct.FileUri = {
544  uniformDataType : 'general.file-uri',
545  oriUri : 'file://data/image/1.png',
546  fileType : 'general.image',
547  details : fileUriDetails,
548}
549let formDetails : Record<string, string> = {
550  'attr1': 'value1',
551  'attr2': 'value2',
552}
553let form : uniformDataStruct.Form = {
554  uniformDataType : 'openharmony.form',
555  formId : 1,
556  formName : 'form',
557  bundleName : 'com.xx.app',
558  abilityName : 'ability',
559  module : 'module',
560  details : formDetails,
561}
562
563let unifiedData = new unifiedDataChannel.UnifiedData();
564let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form);
565record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri);
566unifiedData.addRecord(record);
567```
568
569### getEntry<sup>15+</sup>
570
571getEntry(type: string): ValueType
572
573Obtains data of the specified type from the current data record.
574
575**Atomic service API**: This API can be used in atomic services since API version 15.
576
577**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
578
579**Parameters**
580
581| Name| Type                           | Mandatory| Description                                     |
582| ------ | ------------------------------- | ---- |-----------------------------------------|
583| type | string | Yes  | Type of the data to obtain. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).|
584
585**Return value**
586
587| Type  | Description                                                  |
588| ------ |------------------------------------------------------|
589| [ValueType](#valuetype12) | Value obtained.|
590
591**Error codes**
592
593For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
594
595| **ID**| **Error Message**                               |
596| ------------ | ------------------------------------------- |
597| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
598
599**Example**
600
601```ts
602import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
603
604let fileUriDetails : Record<string, string> = {
605  'attr1': 'value1',
606  'attr2': 'value2',
607}
608let fileUri : uniformDataStruct.FileUri = {
609  uniformDataType : 'general.file-uri',
610  oriUri : 'file://data/image/1.png',
611  fileType : 'general.image',
612  details : fileUriDetails,
613}
614let formDetails : Record<string, string> = {
615  'attr1': 'value1',
616  'attr2': 'value2',
617}
618let form : uniformDataStruct.Form = {
619  uniformDataType : 'openharmony.form',
620  formId : 1,
621  formName : 'form',
622  bundleName : 'com.xx.app',
623  abilityName : 'ability',
624  module : 'module',
625  details : formDetails,
626}
627
628let unifiedData = new unifiedDataChannel.UnifiedData();
629let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form);
630record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri);
631unifiedData.addRecord(record);
632
633let records = unifiedData.getRecords();
634for (let i = 0; i < records.length; i++) {
635  let unifiedDataRecord = records[i] as unifiedDataChannel.UnifiedRecord;
636  let fileUriRead : uniformDataStruct.FileUri = unifiedDataRecord.getEntry(uniformTypeDescriptor.UniformDataType.FILE_URI) as uniformDataStruct.FileUri
637  if (fileUriRead != undefined) {
638    console.info(`oriUri: ${fileUriRead.oriUri}`);
639  }
640}
641```
642
643### getEntries<sup>15+</sup>
644
645getEntries(): Record<string, ValueType>
646
647Obtains all the data in the current data record.
648
649**Atomic service API**: This API can be used in atomic services since API version 15.
650
651**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
652
653**Return value**
654
655| Type  | Description                                                  |
656| ------ |------------------------------------------------------|
657| Record<string, [ValueType](#valuetype12)> | Values and types obtained.|
658
659**Example**
660
661```ts
662import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
663
664let fileUriDetails : Record<string, string> = {
665  'attr1': 'value1',
666  'attr2': 'value2',
667}
668let fileUri : uniformDataStruct.FileUri = {
669  uniformDataType : 'general.file-uri',
670  oriUri : 'file://data/image/1.png',
671  fileType : 'general.image',
672  details : fileUriDetails,
673}
674let formDetails : Record<string, string> = {
675  'attr1': 'value1',
676  'attr2': 'value2',
677}
678let form : uniformDataStruct.Form = {
679  uniformDataType : 'openharmony.form',
680  formId : 1,
681  formName : 'form',
682  bundleName : 'com.xx.app',
683  abilityName : 'ability',
684  module : 'module',
685  details : formDetails,
686}
687
688let unifiedData = new unifiedDataChannel.UnifiedData();
689let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form);
690record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri);
691unifiedData.addRecord(record);
692
693let records = unifiedData.getRecords();
694for (let i = 0; i < records.length; i++) {
695  let unifiedDataRecord = records[i] as unifiedDataChannel.UnifiedRecord;
696  let entries : Record<string, unifiedDataChannel.ValueType> = unifiedDataRecord.getEntries();
697  let formRead : uniformDataStruct.Form = entries[uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM] as uniformDataStruct.Form
698  if (formRead != undefined) {
699    console.info(`formName: ${formRead.formName}`);
700  }
701}
702```
703
704### getTypes<sup>15+</sup>
705
706getTypes(): Array\<string\>
707
708Obtains all the data types in the current data record. You can call this API with a **UnifiedRecord** instance to obtain all types of data in the record.
709
710**Atomic service API**: This API can be used in atomic services since API version 15.
711
712**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
713
714**Return value**
715
716| Type                                    | Description                     |
717| ---------------------------------------- |-------------------------|
718| Array\<string\> | Array of [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype)s obtained.|
719
720**Example**
721
722```ts
723import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData';
724
725let fileUriDetails : Record<string, string> = {
726  'attr1': 'value1',
727  'attr2': 'value2',
728}
729let fileUri : uniformDataStruct.FileUri = {
730  uniformDataType : 'general.file-uri',
731  oriUri : 'file://data/image/1.png',
732  fileType : 'general.image',
733  details : fileUriDetails,
734}
735let formDetails : Record<string, string> = {
736  'attr1': 'value1',
737  'attr2': 'value2',
738}
739let form : uniformDataStruct.Form = {
740  uniformDataType : 'openharmony.form',
741  formId : 1,
742  formName : 'form',
743  bundleName : 'com.xx.app',
744  abilityName : 'ability',
745  module : 'module',
746  details : formDetails,
747}
748
749let unifiedData = new unifiedDataChannel.UnifiedData();
750let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form);
751record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri);
752unifiedData.addRecord(record);
753
754let records = unifiedData.getRecords();
755for (let i = 0; i < records.length; i++) {
756  let unifiedDataRecord = records[i] as unifiedDataChannel.UnifiedRecord;
757  let types : Array<string> = unifiedDataRecord.getTypes();
758  if (types.includes(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM)) {
759    console.info(`types include: ${uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM}`);
760  }
761}
762```
763
764## Text
765
766Represents the text data. It is a child class of [UnifiedRecord](#unifiedrecord) and a base class of text data. You are advised to use the child class of **Text**, for example, [PlainText](#plaintext), [Hyperlink](#hyperlink), and [HTML](#html), to describe data.
767
768**Atomic service API**: This API can be used in atomic services since API version 11.
769
770**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
771
772| Name| Type| Read-Only| Optional| Description|
773| -------- | -------- | -------- | -------- | -------- |
774| details | Record<string, string> | No| Yes| A dictionary type object, where both the key and value are of the string type and are used to describe the text content. For example, a data object with the following content can be created to describe a text file:<br>{<br>"title":"Title",<br>"content":"Content"<br>}<br> The default value is an empty dictionary object.|
775
776**Example**
777
778```ts
779let text = new unifiedDataChannel.Text();
780text.details = {
781  title: 'MyTitle',
782  content: 'this is content',
783};
784let unifiedData = new unifiedDataChannel.UnifiedData(text);
785```
786
787## PlainText
788
789Represents the plaintext data. It is a child class of [Text](#text) and is used to describe plaintext data.
790
791**Atomic service API**: This API can be used in atomic services since API version 11.
792
793**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
794
795| Name| Type| Read-Only| Optional| Description|
796| -------- | -------- | -------- | -------- | -------- |
797| textContent | string | No| No| Plaintext content.               |
798| abstract    | string | No| Yes| Text abstract. This parameter is optional. The default value is an empty string.|
799
800**Example**
801
802```ts
803let text = new unifiedDataChannel.PlainText();
804text.textContent = 'this is textContent';
805text.abstract = 'this is abstract';
806```
807
808## Hyperlink
809
810Represents hyperlink data. It is a child class of [Text](#text) and is used to describe data of the hyperlink type.
811
812**Atomic service API**: This API can be used in atomic services since API version 11.
813
814**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
815
816| Name| Type| Read-Only| Optional| Description|
817| -------- | -------- | -------- | -------- | -------- |
818| url         | string | No| No| URL.      |
819| description | string | No| Yes| Description of the linked content. This parameter is optional. The default value is an empty string.|
820
821**Example**
822
823```ts
824let link = new unifiedDataChannel.Hyperlink();
825link.url = 'www.XXX.com';
826link.description = 'this is description';
827```
828
829## HTML
830
831Represents the HTML data. It is a child class of [Text](#text) and is used to describe HTML data.
832
833**Atomic service API**: This API can be used in atomic services since API version 11.
834
835**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
836
837| Name| Type| Read-Only| Optional| Description|
838| -------- | -------- | -------- | -------- | -------- |
839| htmlContent  | string | No| No| Content in HTML format.            |
840| plainContent | string | No| Yes| Plaintext without HTML tags. This parameter is optional. The default value is an empty string.|
841
842**Example**
843
844```ts
845let html = new unifiedDataChannel.HTML();
846html.htmlContent = '<div><p>Title</p></div>';
847html.plainContent = 'this is plainContent';
848```
849
850## File
851
852Represents the file data. It is a child class of [UnifiedRecord](#unifiedrecord) and a base class of the data of the file type. You are advised to use the child class of **File**, for example, [Image](#image), [Video](#video), and [Folder](#folder), to describe data.
853
854**Atomic service API**: This API can be used in atomic services since API version 11.
855
856**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
857
858| Name| Type| Read-Only| Optional| Description|
859| -------- | -------- | -------- | -------- | -------- |
860| details | Record<string, string> | No| Yes| A dictionary type object, where both the key and value are of the string type and are used to describe file information. For example, a data object with the following content can be created to describe a file:<br>{<br>"name":"File name",<br>"type":"File type"<br>}<br> The default value is an empty dictionary object.|
861| uri     | string                    | No| No| URI of the file data.                                                                                                                                            |
862
863**Example**
864
865```ts
866let file = new unifiedDataChannel.File();
867file.details = {
868    name: 'test',
869    type: 'txt',
870};
871file.uri = 'schema://com.samples.test/files/test.txt';
872```
873
874## Image
875
876Represents the image data. It is a child class of [File](#file) and is used to describe images.
877
878**Atomic service API**: This API can be used in atomic services since API version 11.
879
880**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
881
882| Name| Type| Read-Only| Optional| Description|
883| -------- | -------- | -------- | -------- | -------- |
884| imageUri | string | No| No| URI of the image.|
885
886**Example**
887
888```ts
889let image = new unifiedDataChannel.Image();
890image.imageUri = 'schema://com.samples.test/files/test.jpg';
891```
892
893## Video
894
895Represents video data. It is a child class of [File](#file) and is used to describe a video file.
896
897**Atomic service API**: This API can be used in atomic services since API version 11.
898
899**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
900
901| Name| Type| Read-Only| Optional| Description|
902| -------- | -------- | -------- | -------- | -------- |
903| videoUri | string | No| No| URI of the video file.|
904
905**Example**
906
907```ts
908let video = new unifiedDataChannel.Video();
909video.videoUri = 'schema://com.samples.test/files/test.mp4';
910```
911
912## Audio
913
914Represents audio data. It is a child class of [File](#file) and is used to describe an audio file.
915
916**Atomic service API**: This API can be used in atomic services since API version 11.
917
918**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
919
920| Name| Type| Read-Only| Optional| Description|
921| -------- | -------- | -------- | -------- | -------- |
922| audioUri | string | No| No| Audio data URI.|
923
924**Example**
925
926```ts
927let audio = new unifiedDataChannel.Audio();
928audio.audioUri = 'schema://com.samples.test/files/test.mp3';
929```
930
931## Folder
932
933Represents the folder data. It is a child class of [File](#file) and is used to describe a folder.
934
935**Atomic service API**: This API can be used in atomic services since API version 11.
936
937**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
938
939| Name| Type| Read-Only| Optional| Description|
940| -------- | -------- | -------- | -------- | -------- |
941| folderUri | string | No| No| URI of the folder.|
942
943**Example**
944
945```ts
946let folder = new unifiedDataChannel.Folder();
947folder.folderUri = 'schema://com.samples.test/files/folder/';
948```
949
950## SystemDefinedRecord
951
952Represents specific data types defined by OpenHarmony. It is a child class of [UnifiedRecord](#unifiedrecord) and a base class of OpenHarmony-specific data types. You are advised to use the child class of **SystemDefinedRecord**, for example, [SystemDefinedForm](#systemdefinedform), [SystemDefinedAppItem](#systemdefinedappitem), and [SystemDefinedPixelMap](#systemdefinedpixelmap), to describe OpenHarmony-specific data.
953
954**Atomic service API**: This API can be used in atomic services since API version 11.
955
956**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
957
958| Name| Type| Read-Only| Optional| Description|
959| -------- | -------- | -------- | -------- | -------- |
960| details | Record<string, number \| string \| Uint8Array> | No| Yes| A dictionary type object, where the key is of the string type, and the value can be a number, a string, or a Uint8Array. The default value is an empty dictionary object.|
961
962**Example**
963
964```ts
965let sdr = new unifiedDataChannel.SystemDefinedRecord();
966let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
967sdr.details = {
968    title: 'recordTitle',
969    version: 1,
970    content: u8Array,
971};
972let unifiedData = new unifiedDataChannel.UnifiedData(sdr);
973```
974
975## SystemDefinedForm
976
977Represents the service widget data defined by the system. It is a child class of [SystemDefinedRecord](#systemdefinedrecord).
978
979**Atomic service API**: This API can be used in atomic services since API version 11.
980
981**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
982
983| Name| Type| Read-Only| Optional| Description|
984| -------- | -------- | -------- | -------- | -------- |
985| formId      | number | No| No| Service widget ID.         |
986| formName    | string | No| No| Widget name.         |
987| bundleName  | string | No| No| Name of the bundle to which the widget belongs.  |
988| abilityName | string | No| No| Ability name corresponding to the widget.|
989| module      | string | No| No| Name of the module to which the widget belongs.  |
990
991**Example**
992
993```ts
994let form = new unifiedDataChannel.SystemDefinedForm();
995form.formId = 123456;
996form.formName = 'MyFormName';
997form.bundleName = 'MyBundleName';
998form.abilityName = 'MyAbilityName';
999form.module = 'MyModule';
1000let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1001form.details = {
1002  formKey1: 123,
1003  formKey2: 'formValue',
1004  formKey3: u8Array,
1005};
1006let unifiedData = new unifiedDataChannel.UnifiedData(form);
1007```
1008
1009## SystemDefinedAppItem
1010
1011Represents the data of the home screen icon defined by the system. It is a child class of [SystemDefinedRecord](#systemdefinedrecord).
1012
1013**Atomic service API**: This API can be used in atomic services since API version 11.
1014
1015**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1016
1017| Name| Type| Read-Only| Optional| Description|
1018| -------- | -------- | -------- | -------- | -------- |
1019| appId       | string | No| No| ID of the application, for which the icon is used.     |
1020| appName     | string | No| No| Name of the application, for which the icon is used.      |
1021| appIconId   | string | No| No| Image ID of the icon.       |
1022| appLabelId  | string | No| No| Label ID corresponding to the icon name.   |
1023| bundleName  | string | No| No| Bundle name corresponding to the icon.|
1024| abilityName | string | No| No| Application ability name corresponding to the icon.|
1025
1026**Example**
1027
1028```ts
1029let appItem = new unifiedDataChannel.SystemDefinedAppItem();
1030appItem.appId = 'MyAppId';
1031appItem.appName = 'MyAppName';
1032appItem.appIconId = 'MyAppIconId';
1033appItem.appLabelId = 'MyAppLabelId';
1034appItem.bundleName = 'MyBundleName';
1035appItem.abilityName = 'MyAbilityName';
1036let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1037appItem.details = {
1038    appItemKey1: 123,
1039    appItemKey2: 'appItemValue',
1040    appItemKey3: u8Array,
1041};
1042let unifiedData = new unifiedDataChannel.UnifiedData(appItem);
1043```
1044
1045## SystemDefinedPixelMap
1046
1047Represents the image data type corresponding to [PixelMap](../apis-image-kit/js-apis-image.md#pixelmap7) defined by the system. It is a child class of [SystemDefinedRecord](#systemdefinedrecord) and holds only binary data of PixelMap.
1048
1049**Atomic service API**: This API can be used in atomic services since API version 11.
1050
1051**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1052
1053| Name| Type| Read-Only| Optional| Description|
1054| -------- | -------- | -------- | -------- | -------- |
1055| rawData | Uint8Array | No| No| Binary data of the **PixelMap** object.|
1056
1057**Example**
1058
1059```ts
1060import { image } from '@kit.ImageKit';  // Module where the PixelMap class is defined.
1061import { unifiedDataChannel, uniformTypeDescriptor } from '@kit.ArkData';
1062import { BusinessError } from '@kit.BasicServicesKit';
1063
1064const color = new ArrayBuffer(96); // Create a PixelMap object.
1065let opts: image.InitializationOptions = {
1066  editable: true, pixelFormat: 3, size: {
1067    height: 4, width: 6
1068  }
1069}
1070image.createPixelMap(color, opts, (error, pixelmap) => {
1071  if (error) {
1072    console.error('Failed to create pixelmap.');
1073  } else {
1074    console.info('Succeeded in creating pixelmap.');
1075    let arrayBuf = new ArrayBuffer(pixelmap.getPixelBytesNumber());
1076    pixelmap.readPixelsToBuffer(arrayBuf);
1077    let u8Array = new Uint8Array(arrayBuf);
1078    let sdpixel = new unifiedDataChannel.SystemDefinedPixelMap();
1079    sdpixel.rawData = u8Array;
1080    let unifiedData = new unifiedDataChannel.UnifiedData(sdpixel);
1081
1082    // Read the record of the pixelMap type from unifiedData.
1083    let records = unifiedData.getRecords();
1084    for (let i = 0; i < records.length; i++) {
1085      if (records[i].getType() === uniformTypeDescriptor.UniformDataType.OPENHARMONY_PIXEL_MAP) {
1086        let pixelmapRecord = records[i] as unifiedDataChannel.SystemDefinedPixelMap;
1087        let newArraybuf = pixelmapRecord.rawData.buffer;
1088        pixelmap.writeBufferToPixels(newArraybuf).then(() => {
1089          console.info('Succeeded in writing data from buffer to a pixelMap');
1090        }).catch((error: BusinessError) => {
1091          console.error(`Failed to write data from a buffer to a PixelMap. code is ${error.code}, message is ${error.message}`);
1092        })
1093      }
1094    }
1095  }
1096})
1097```
1098
1099## ApplicationDefinedRecord
1100
1101Represents the custom data type for applications only. It is a child class of [UnifiedRecord](#unifiedrecord) and a base class of custom data types of applications. Applications can extend custom data types based on this class.
1102
1103**Atomic service API**: This API can be used in atomic services since API version 11.
1104
1105**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1106
1107| Name| Type| Read-Only| Optional| Description|
1108| -------- | -------- | -------- | -------- | -------- |
1109| applicationDefinedType | string     | No| No| Application's custom data type identifier, which must start with **ApplicationDefined**.|
1110| rawData                | Uint8Array | No| No| Binary data of the custom data type.                     |
1111
1112**Example**
1113
1114```ts
1115let record = new unifiedDataChannel.ApplicationDefinedRecord();
1116let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
1117record.applicationDefinedType = 'ApplicationDefinedType';
1118record.rawData = u8Array;
1119let unifiedData = new unifiedDataChannel.UnifiedData(record);
1120```
1121
1122## Intention
1123
1124Enumerates the data channel types supported by the UDMF. It is used to identify different service scenarios, to which the UDMF data channels apply.
1125
1126**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1127
1128| Name      | Value        | Description     |
1129|----------|-----------|---------|
1130| DATA_HUB | 'DataHub' | Public data channel.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
1131| DRAG<sup>14+</sup> | 'Drag' | Channel in which data can be dragged and dropped.<br>**Model restriction**: This API can be used only in the stage model.|
1132
1133## Options
1134
1135type Options = { intention?: Intention; key?: string; }
1136
1137Defines the data operation performed by the UDMF. It includes two optional parameters: **intention** and **key**. The two parameters can be left unspecified. For details, see the parameter description of the specific API.
1138
1139**Atomic service API**: This API can be used in atomic services since API version 11.
1140
1141**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1142
1143| Name     | Type                   | Mandatory| Description                                                        |
1144| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
1145| intention | [Intention](#intention) | No  | Type of the data channel related to the data operation.                            |
1146| key       | string                  | No  | Unique identifier of the data object in the UDMF, which can be obtained from the value returned by [insertData](#unifieddatachannelinsertdata).<br>The key consists of **udmf:/**, **intention**, **bundleName**, and **groupId** with a (/) in between, for example, **udmf://DataHub/com.ohos.test/0123456789**.<br>**udmf:/** is fixed, **DataHub** is an enum of **intention**, **com.ohos.test** is the bundle name, and **0123456789** is a group ID randomly generated.|
1147
1148## FileConflictOptions<sup>15+</sup>
1149
1150Enumerates the options for resolving file copy conflicts.
1151
1152**Atomic service API**: This API can be used in atomic services since API version 15.
1153
1154**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1155
1156| Name     | Value  | Description            |
1157| --------- | ---- |----------------|
1158| OVERWRITE | 0    | Overwrite the file with the same name in the destination directory.|
1159| SKIP      | 1    | Skip the file if there is a file with the same name in the destination directory.|
1160
1161## ProgressIndicator<sup>15+</sup>
1162
1163Enumerates the progress indicator options.
1164
1165**Atomic service API**: This API can be used in atomic services since API version 15.
1166
1167**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1168
1169| Name   | Value  | Description                                |
1170| ------- | ---- |------------------------------------|
1171| NONE    | 0    | Do not use the default progress indicator.                      |
1172| DEFAULT | 1    | Use the default progress indicator. If data is obtained within 500 ms, the default progress bar is not started.|
1173
1174## ListenerStatus<sup>15+</sup>
1175
1176Enumerates the status codes returned when data is obtained from the UDMF.
1177
1178**Atomic service API**: This API can be used in atomic services since API version 15.
1179
1180**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1181
1182| Name   | Value  | Description                                          |
1183| ------- |-----|----------------------------------------------|
1184| FINISHED | 0   | The task is completed.                                      |
1185| PROCESSING | 1   | The task is being processed.                                    |
1186| CANCELED | 2   | The task is canceled.                                 |
1187| INNER_ERROR  | 200 | An internal error occurs.                                  |
1188| INVALID_PARAMETERS | 201 | [GetDataParams](#getdataparams15) contains invalid parameters.|
1189| DATA_NOT_FOUND | 202 | No data is obtained.                                  |
1190| SYNC_FAILED | 203 | Failed to sync data.                                |
1191| COPY_FILE_FAILED | 204 | Failed to copy data.                              |
1192
1193## ProgressInfo<sup>15+</sup>
1194
1195Represents the progress information.
1196
1197**Atomic service API**: This API can be used in atomic services since API version 15.
1198
1199**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1200
1201| Name    | Type                                 | Readable| Writable| Description                                                            |
1202| -------- |-------------------------------------| ---- | ---- |----------------------------------------------------------------|
1203| progress | number                              | Yes  | No  | Progress of the drag task, in percentage. <br>The value is an integer ranging from -1 to 100. The value **-1** indicates a failure to obtain data, and the value **100** indicates data is obtained.|
1204| status | [ListenerStatus](#listenerstatus15) | Yes  | No  | Status code of the drag task reported by the system.                                                 |
1205
1206## DataProgressListener<sup>15+</sup>
1207
1208type DataProgressListener = (progressInfo: ProgressInfo, data: UnifiedData | null) => void
1209
1210Defines the callback used to return the data retrieval progress information and data obtained.
1211
1212**Atomic service API**: This API can be used in atomic services since API version 15.
1213
1214**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1215
1216**Parameters**
1217
1218| Name     | Type                           | Mandatory   | Description          |
1219|----------|-------------------------------|-------|--------------|
1220| progressInfo| [ProgressInfo](#progressinfo15) | Yes    | Progress information to report.|
1221| data        | [UnifiedData](#unifieddata)  \| null  |  Yes   | Data obtained when the progress reaches 100. If the progress does not reach 100, **null** is returned.|
1222
1223## GetDataParams<sup>15+</sup>
1224
1225Represents the parameters for obtaining data from UDMF, including the destination directory, option for resolving file conflicts, and progress indicator type.
1226
1227For details, see [Obtaining Data Asynchronously Through Drag-and-Drop](../apis-arkui/arkui-ts/ts-universal-events-drag-drop.md#example-3-obtaining-data-asynchronously-through-drag-and-drop).
1228
1229**Atomic service API**: This API can be used in atomic services since API version 15.
1230
1231**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1232
1233**Parameters**
1234
1235| Name                  | Type                                             | Mandatory| Description                                                                                                                                                |
1236|----------------------|-------------------------------------------------| ---- |----------------------------------------------------------------------------------------------------------------------------------------------------|
1237| progressIndicator    | [ProgressIndicator](#progressindicator15)       | Yes| Progress indicator options. You can use the default progress indicator as required.                                                                                                                        |
1238| dataProgressListener | [DataProgressListener](#dataprogresslistener15) | Yes| Callback used to return the data retrieval progress and data obtained.                                                                                                                               |
1239| destUri              | string                                          | No| Destination directory for the file copied. If file processing is not supported, leave this parameter unspecified, which is the default value of this parameter. If file processing is supported, pass in an existing directory. If complex file processing policies are involved or multipathing file storage is required, you are advised to leave this parameter unspecified and let the application handle file copying. If this parameter is not specified, the source URI is obtained. If this parameter is specified, the specified destination URI is obtained.|
1240| fileConflictOptions  | [FileConflictOptions](#fileconflictoptions15)   | No  | Option for resolving file copy conflicts. The default value is **OVERWRITE**.                                                                                                                        |
1241
1242## unifiedDataChannel.insertData
1243
1244insertData(options: Options, data: UnifiedData, callback: AsyncCallback&lt;string&gt;): void
1245
1246Inserts data to the UDMF public data channel. This API uses an asynchronous callback to return the unique identifier of the data inserted.
1247
1248**Atomic service API**: This API can be used in atomic services since API version 11.
1249
1250**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1251
1252**Parameters**
1253
1254| Name     | Type                        | Mandatory| Description                          |
1255|----------|----------------------------|----|------------------------------|
1256| options  | [Options](#options)        | Yes | Configuration for the data insertion operation. The **intention** field is mandatory. If it is not specified, error code 401 will be returned. The settings of other parameters do not affect the use of this API.       |
1257| data     | [UnifiedData](#unifieddata) | Yes | Data to insert.                       |
1258| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the key (unique identifier) of the data inserted.|
1259
1260**Error codes**
1261
1262For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1263
1264| **ID**| **Error Message**                               |
1265| ------------ | ------------------------------------------- |
1266| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1267
1268**Example**
1269
1270```ts
1271import { unifiedDataChannel } from '@kit.ArkData';
1272import { BusinessError } from '@kit.BasicServicesKit';
1273
1274let plainText = new unifiedDataChannel.PlainText();
1275plainText.textContent = 'hello world!';
1276let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
1277
1278let options: unifiedDataChannel.Options = {
1279  intention: unifiedDataChannel.Intention.DATA_HUB
1280}
1281try {
1282  unifiedDataChannel.insertData(options, unifiedData, (err, data) => {
1283    if (err === undefined) {
1284      console.info(`Succeeded in inserting data. key = ${data}`);
1285    } else {
1286      console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `);
1287    }
1288  });
1289  } catch (e) {
1290    let error: BusinessError = e as BusinessError;
1291    console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `);
1292}
1293
1294```
1295
1296## unifiedDataChannel.insertData
1297
1298insertData(options: Options, data: UnifiedData): Promise&lt;string&gt;
1299
1300Inserts data to the UDMF public data channel. This API uses a promise to return the unique identifier of the data inserted.
1301
1302**Atomic service API**: This API can be used in atomic services since API version 11.
1303
1304**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1305
1306**Parameters**
1307
1308| Name    | Type                         | Mandatory| Description                   |
1309|---------|-----------------------------|----|-----------------------|
1310| options | [Options](#options)         | Yes | Configuration for the data insertion operation. The **intention** field is mandatory. If it is not specified, error code 401 will be returned. The settings of other parameters do not affect the use of this API.|
1311| data    | [UnifiedData](#unifieddata) | Yes | Data to insert.                |
1312
1313**Return value**
1314
1315| Type                   | Description                               |
1316|-----------------------|-----------------------------------|
1317| Promise&lt;string&gt; | Promise used to return the key of the data inserted.|
1318
1319**Error codes**
1320
1321For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1322
1323| **ID**| **Error Message**                               |
1324| ------------ | ------------------------------------------- |
1325| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1326
1327**Example**
1328
1329```ts
1330import { unifiedDataChannel } from '@kit.ArkData';
1331import { BusinessError } from '@kit.BasicServicesKit';
1332
1333let plainText = new unifiedDataChannel.PlainText();
1334plainText.textContent = 'hello world!';
1335let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
1336
1337let options: unifiedDataChannel.Options = {
1338  intention: unifiedDataChannel.Intention.DATA_HUB
1339}
1340try {
1341  unifiedDataChannel.insertData(options, unifiedData).then((data) => {
1342    console.info(`Succeeded in inserting data. key = ${data}`);
1343  }).catch((err: BusinessError) => {
1344    console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `);
1345  });
1346} catch (e) {
1347  let error: BusinessError = e as BusinessError;
1348  console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `);
1349}
1350```
1351
1352## unifiedDataChannel.updateData
1353
1354updateData(options: Options, data: UnifiedData, callback: AsyncCallback&lt;void&gt;): void
1355
1356Updates the data in the UDMF public data channel. This API uses an asynchronous callback to return the result.
1357
1358**Atomic service API**: This API can be used in atomic services since API version 11.
1359
1360**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1361
1362**Parameters**
1363
1364| Name     | Type                         | Mandatory| Description                                 |
1365|----------|-----------------------------|----|-------------------------------------|
1366| options  | [Options](#options)         | Yes | Configuration for the data update operation. The **key** field is mandatory. If it is not specified, error code 401 will be returned. The settings of other parameters do not affect the use of this API.                    |
1367| data     | [UnifiedData](#unifieddata) | Yes | New data.                              |
1368| callback | AsyncCallback&lt;void&gt;   | Yes | Callback used to return the result. If the data is updated successfully, **err** is **undefined**. Otherwise, **err** is an error object.|
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| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1377
1378**Example**
1379
1380```ts
1381import { unifiedDataChannel } from '@kit.ArkData';
1382import { BusinessError } from '@kit.BasicServicesKit';
1383
1384let plainText = new unifiedDataChannel.PlainText();
1385plainText.textContent = 'hello world!';
1386let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
1387
1388let options: unifiedDataChannel.Options = {
1389  key: 'udmf://DataHub/com.ohos.test/0123456789'
1390};
1391
1392try {
1393  unifiedDataChannel.updateData(options, unifiedData, (err) => {
1394    if (err === undefined) {
1395      console.info('Succeeded in updating data.');
1396    } else {
1397      console.error(`Failed to update data. code is ${err.code},message is ${err.message} `);
1398    }
1399  });
1400} catch (e) {
1401  let error: BusinessError = e as BusinessError;
1402  console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `);
1403}
1404```
1405
1406## unifiedDataChannel.updateData
1407
1408updateData(options: Options, data: UnifiedData): Promise&lt;void&gt;
1409
1410Updates the data in the UDMF public data channel. This API uses a promise to return the result.
1411
1412**Atomic service API**: This API can be used in atomic services since API version 11.
1413
1414**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1415
1416**Parameters**
1417
1418| Name    | Type                         | Mandatory| Description             |
1419|---------|-----------------------------|----|-----------------|
1420| options | [Options](#options)         | Yes | Configuration for the data update operation. The **key** field is mandatory. If it is not specified, error code 401 will be returned. The settings of other parameters do not affect the use of this API.|
1421| data    | [UnifiedData](#unifieddata) | Yes | New data.          |
1422
1423**Return value**
1424
1425| Type                 | Description                        |
1426|---------------------|----------------------------|
1427| Promise&lt;void&gt; | Promise that returns no value.|
1428
1429**Error codes**
1430
1431For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1432
1433| **ID**| **Error Message**                               |
1434| ------------ | ------------------------------------------- |
1435| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1436
1437**Example**
1438
1439```ts
1440import { unifiedDataChannel } from '@kit.ArkData';
1441import { BusinessError } from '@kit.BasicServicesKit';
1442
1443let plainText = new unifiedDataChannel.PlainText();
1444plainText.textContent = 'hello world!';
1445let unifiedData = new unifiedDataChannel.UnifiedData(plainText);
1446
1447let options: unifiedDataChannel.Options = {
1448  key: 'udmf://DataHub/com.ohos.test/0123456789'
1449};
1450
1451try {
1452  unifiedDataChannel.updateData(options, unifiedData).then(() => {
1453    console.info('Succeeded in updating data.');
1454  }).catch((err: BusinessError) => {
1455    console.error(`Failed to update data. code is ${err.code},message is ${err.message} `);
1456  });
1457} catch (e) {
1458  let error: BusinessError = e as BusinessError;
1459  console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `);
1460}
1461```
1462
1463## unifiedDataChannel.queryData
1464
1465queryData(options: Options, callback: AsyncCallback&lt;Array&lt;UnifiedData&gt;&gt;): void
1466
1467Queries data in the UDMF public data channel. This API uses an asynchronous callback to return the result.
1468
1469**Atomic service API**: This API can be used in atomic services since API version 11.
1470
1471**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1472
1473**Parameters**
1474
1475| Name     | Type                                                           | Mandatory| Description                                                                                                                                                              |
1476|----------|---------------------------------------------------------------|----|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1477| options  | [Options](#options)                                           | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in.                                                                                                                   |
1478| callback | AsyncCallback&lt;Array&lt;[UnifiedData](#unifieddata)&gt;&gt; | Yes | Callback used to return the queried data.<br>If only the **key** is specified in **options**, the data corresponding to the key is returned.<br>If only the **intention** is specified in **options**, all data in the **intention** is returned.<br>If both **intention** and **key** are specified, the intersection of the two is returned, which is the result obtained when only **key** is specified. If there is no intersection between the specified **intention** and **key**, an error object is returned.|
1479
1480**Error codes**
1481
1482For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1483
1484| **ID**| **Error Message**                               |
1485| ------------ | ------------------------------------------- |
1486| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1487
1488**Example**
1489
1490```ts
1491import { unifiedDataChannel } from '@kit.ArkData';
1492import { uniformTypeDescriptor } from '@kit.ArkData';
1493import { BusinessError } from '@kit.BasicServicesKit';
1494
1495let options: unifiedDataChannel.Options = {
1496  intention: unifiedDataChannel.Intention.DATA_HUB
1497};
1498
1499try {
1500  unifiedDataChannel.queryData(options, (err, data) => {
1501    if (err === undefined) {
1502      console.info(`Succeeded in querying data. size = ${data.length}`);
1503      for (let i = 0; i < data.length; i++) {
1504        let records = data[i].getRecords();
1505        for (let j = 0; j < records.length; j++) {
1506          if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
1507            let text = records[j] as unifiedDataChannel.PlainText;
1508            console.info(`${i + 1}.${text.textContent}`);
1509          }
1510        }
1511      }
1512    } else {
1513      console.error(`Failed to query data. code is ${err.code},message is ${err.message} `);
1514    }
1515  });
1516} catch (e) {
1517  let error: BusinessError = e as BusinessError;
1518  console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
1519}
1520```
1521
1522## unifiedDataChannel.queryData
1523
1524queryData(options: Options): Promise&lt;Array&lt;UnifiedData&gt;&gt;
1525
1526Queries data in the UDMF public data channel. This API uses a promise to return the result.
1527
1528**Atomic service API**: This API can be used in atomic services since API version 11.
1529
1530**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1531
1532**Parameters**
1533
1534| Name    | Type                 | Mandatory| Description                                           |
1535|---------|---------------------|----|-----------------------------------------------|
1536| options | [Options](#options) | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in.|
1537
1538**Return value**
1539
1540| Type                                                     | Description                                                                                                                                 |
1541|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
1542| Promise&lt;Array&lt;[UnifiedData](#unifieddata)&gt;&gt; | Promise used to return the result.<br>If only the **key** is specified in **options**, the data corresponding to the key is returned.<br>If only the **intention** is specified in **options**, all data in the **intention** is returned.<br>If both **intention** and **key** are specified, the intersection of the two is returned, which is the result obtained when only **key** is specified. If there is no intersection between the specified **intention** and **key**, an error object is returned.|
1543
1544**Error codes**
1545
1546For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1547
1548| **ID**| **Error Message**                               |
1549| ------------ | ------------------------------------------- |
1550| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1551
1552**Example**
1553
1554```ts
1555import { unifiedDataChannel } from '@kit.ArkData';
1556import { uniformTypeDescriptor } from '@kit.ArkData';
1557import { BusinessError } from '@kit.BasicServicesKit';
1558
1559let options: unifiedDataChannel.Options = {
1560  key: 'udmf://DataHub/com.ohos.test/0123456789'
1561};
1562
1563try {
1564  unifiedDataChannel.queryData(options).then((data) => {
1565    console.info(`Succeeded in querying data. size = ${data.length}`);
1566    for (let i = 0; i < data.length; i++) {
1567      let records = data[i].getRecords();
1568      for (let j = 0; j < records.length; j++) {
1569        if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
1570          let text = records[j] as unifiedDataChannel.PlainText;
1571          console.info(`${i + 1}.${text.textContent}`);
1572        }
1573      }
1574    }
1575  }).catch((err: BusinessError) => {
1576    console.error(`Failed to query data. code is ${err.code},message is ${err.message} `);
1577  });
1578} catch (e) {
1579  let error: BusinessError = e as BusinessError;
1580  console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
1581}
1582```
1583
1584## unifiedDataChannel.deleteData
1585
1586deleteData(options: Options, callback: AsyncCallback&lt;Array&lt;UnifiedData&gt;&gt;): void
1587
1588Deletes data from the UDMF public data channel. This API uses an asynchronous callback to return the result.
1589
1590**Atomic service API**: This API can be used in atomic services since API version 11.
1591
1592**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1593
1594**Parameters**
1595
1596| Name     | Type                                                           | Mandatory| Description                                                                                                                                                                                    |
1597|----------|---------------------------------------------------------------|----|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1598| options  | [Options](#options)                                           | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in.                                                                                                                                         |
1599| callback | AsyncCallback&lt;Array&lt;[UnifiedData](#unifieddata)&gt;&gt; | Yes | Callback used to return the data deleted.<br>If only the **key** is specified in **options**, the data corresponding to the key deleted is returned.<br>If only the **intention** is specified in **options**, all data in the **intention** deleted is returned.<br>If both **intention** and **key** are specified, the intersection of the two deleted is returned. If there is no intersection between the two, an error object is returned.|
1600
1601**Error codes**
1602
1603For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1604
1605| **ID**| **Error Message**                               |
1606| ------------ | ------------------------------------------- |
1607| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1608
1609**Example**
1610
1611```ts
1612import { unifiedDataChannel } from '@kit.ArkData';
1613import { uniformTypeDescriptor } from '@kit.ArkData';
1614import { BusinessError } from '@kit.BasicServicesKit';
1615
1616let options: unifiedDataChannel.Options = {
1617  intention: unifiedDataChannel.Intention.DATA_HUB
1618};
1619
1620try {
1621  unifiedDataChannel.deleteData(options, (err, data) => {
1622    if (err === undefined) {
1623      console.info(`Succeeded in deleting data. size = ${data.length}`);
1624      for (let i = 0; i < data.length; i++) {
1625        let records = data[i].getRecords();
1626        for (let j = 0; j < records.length; j++) {
1627          if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
1628            let text = records[j] as unifiedDataChannel.PlainText;
1629            console.info(`${i + 1}.${text.textContent}`);
1630          }
1631        }
1632      }
1633    } else {
1634      console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `);
1635    }
1636  });
1637} catch (e) {
1638  let error: BusinessError = e as BusinessError;
1639  console.error(`Delete data throws an exception. code is ${error.code},message is ${error.message} `);
1640}
1641```
1642
1643## unifiedDataChannel.deleteData
1644
1645deleteData(options: Options): Promise&lt;Array&lt;UnifiedData&gt;&gt;
1646
1647Deletes data from the UDMF public data channel. This API uses a promise to return the result.
1648
1649**Atomic service API**: This API can be used in atomic services since API version 11.
1650
1651**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1652
1653**Parameters**
1654
1655| Name    | Type                 | Mandatory| Description    |
1656|---------|---------------------|----|--------|
1657| options | [Options](#options) | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in.|
1658
1659**Return value**
1660
1661| Type                                                     | Description                                                                                                                                                         |
1662|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
1663| Promise&lt;Array&lt;[UnifiedData](#unifieddata)&gt;&gt; | Promise used to return the data deleted.<br>If only the **key** is specified in **options**, the data corresponding to the key deleted is returned.<br>If only the **intention** is specified in **options**, all data in the **intention** deleted is returned.<br>If both **intention** and **key** are specified, the intersection of the two deleted is returned. If there is no intersection between the two, an error object is returned.|
1664
1665**Error codes**
1666
1667For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1668
1669| **ID**| **Error Message**                               |
1670| ------------ | ------------------------------------------- |
1671| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types.  |
1672
1673**Example**
1674
1675```ts
1676import { unifiedDataChannel } from '@kit.ArkData';
1677import { uniformTypeDescriptor } from '@kit.ArkData';
1678import { BusinessError } from '@kit.BasicServicesKit';
1679
1680let options: unifiedDataChannel.Options = {
1681  key: 'udmf://DataHub/com.ohos.test/0123456789'
1682};
1683
1684try {
1685  unifiedDataChannel.deleteData(options).then((data) => {
1686    console.info(`Succeeded in deleting data. size = ${data.length}`);
1687    for (let i = 0; i < data.length; i++) {
1688      let records = data[i].getRecords();
1689      for (let j = 0; j < records.length; j++) {
1690        if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) {
1691          let text = records[j] as unifiedDataChannel.PlainText;
1692          console.info(`${i + 1}.${text.textContent}`);
1693        }
1694      }
1695    }
1696  }).catch((err: BusinessError) => {
1697    console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `);
1698  });
1699} catch (e) {
1700  let error: BusinessError = e as BusinessError;
1701  console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `);
1702}
1703```
1704
1705## unifiedDataChannel.setAppShareOptions<sup>14+</sup>
1706
1707setAppShareOptions(intention: Intention, shareOptions: ShareOptions): void
1708
1709Sets [ShareOptions](#shareoptions12) for the application data. Currently, only the drag-and-drop data channel is supported.
1710
1711**Required permissions**: ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION
1712
1713**Model restriction**: This API can be used only in the stage model.
1714
1715**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1716
1717**Parameters**
1718
1719| Name     | Type                        | Mandatory| Description                          |
1720|----------|----------------------------|----|------------------------------|
1721| intention | [Intention](#intention) | Yes | Type of the data channel. Currently, only the data channel of the **DRAG** type is supported.|
1722| shareOptions | [ShareOptions](#shareoptions12) | Yes | Usage scope of the [UnifiedData](#unifieddata).|
1723
1724**Error codes**
1725
1726For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [UDMF Error Codes](errorcode-udmf.md).
1727
1728| **ID**| **Error Message**                                                |
1729| ------------ | ------------------------------------------------------------ |
1730| 201          | Permission denied. Interface caller does not have permission "ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION". |
1731| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1732| 20400001     | Settings already exist.                                      |
1733
1734**Example**
1735
1736```ts
1737import { BusinessError } from '@kit.BasicServicesKit';
1738try {
1739  unifiedDataChannel.setAppShareOptions(unifiedDataChannel.Intention.DRAG, unifiedDataChannel.ShareOptions.IN_APP);
1740  console.info(`[UDMF]setAppShareOptions success. `);
1741}catch (e){
1742  let error: BusinessError = e as BusinessError;
1743  console.error(`[UDMF]setAppShareOptions throws an exception. code is ${error.code},message is ${error.message} `);
1744}
1745```
1746
1747## unifiedDataChannel.removeAppShareOptions<sup>14+</sup>
1748
1749removeAppShareOptions(intention: Intention): void
1750
1751Removes the **ShareOptions** set by [setAppShareOptions](#unifieddatachannelsetappshareoptions14).
1752
1753**Required permissions**: ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION
1754
1755**Model restriction**: This API can be used only in the stage model.
1756
1757**System capability**: SystemCapability.DistributedDataManager.UDMF.Core
1758
1759**Parameters**
1760
1761| Name   | Type                   | Mandatory| Description                                                        |
1762| --------- | ----------------------- | ---- | ------------------------------------------------------------ |
1763| intention | [Intention](#intention) | Yes  | Type of the data channel. Currently, only the data channel of the **DRAG** type is supported.|
1764
1765**Error codes**
1766
1767For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1768
1769| **ID**| **Error Message**                                                |
1770| ------------ | ------------------------------------------------------------ |
1771| 201          | Permission denied. Interface caller does not have permission "ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION". |
1772| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1773
1774**Example**
1775
1776```ts
1777import { BusinessError } from '@kit.BasicServicesKit';
1778try {
1779  unifiedDataChannel.removeAppShareOptions(unifiedDataChannel.Intention.DRAG);
1780  console.info(`[UDMF]removeAppShareOptions success. `);
1781}catch (e){
1782  let error: BusinessError = e as BusinessError;
1783  console.error(`[UDMF]removeAppShareOptions throws an exception. code is ${error.code},message is ${error.message} `);
1784}
1785```
1786