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| **ID**| **Error Message** | 592| ------------ | ------------------------------------------- | 593| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 594 595**Example** 596 597```ts 598import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData'; 599 600let fileUriDetails : Record<string, string> = { 601 'attr1': 'value1', 602 'attr2': 'value2', 603} 604let fileUri : uniformDataStruct.FileUri = { 605 uniformDataType : 'general.file-uri', 606 oriUri : 'file://data/image/1.png', 607 fileType : 'general.image', 608 details : fileUriDetails, 609} 610let formDetails : Record<string, string> = { 611 'attr1': 'value1', 612 'attr2': 'value2', 613} 614let form : uniformDataStruct.Form = { 615 uniformDataType : 'openharmony.form', 616 formId : 1, 617 formName : 'form', 618 bundleName : 'com.xx.app', 619 abilityName : 'ability', 620 module : 'module', 621 details : formDetails, 622} 623 624let unifiedData = new unifiedDataChannel.UnifiedData(); 625let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form); 626record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri); 627unifiedData.addRecord(record); 628 629let records = unifiedData.getRecords(); 630for (let i = 0; i < records.length; i++) { 631 let unifiedDataRecord = records[i] as unifiedDataChannel.UnifiedRecord; 632 let fileUriRead : uniformDataStruct.FileUri = unifiedDataRecord.getEntry(uniformTypeDescriptor.UniformDataType.FILE_URI) as uniformDataStruct.FileUri 633 if (fileUriRead != undefined) { 634 console.info(`oriUri: ${fileUriRead.oriUri}`); 635 } 636} 637``` 638 639### getEntries<sup>15+</sup> 640 641getEntries(): Record<string, ValueType> 642 643Obtains all the data in the current data record. 644 645**Atomic service API**: This API can be used in atomic services since API version 15. 646 647**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 648 649**Return value** 650 651| Type | Description | 652| ------ |------------------------------------------------------| 653| Record<string, [ValueType](#valuetype12)> | Values and types obtained.| 654 655**Example** 656 657```ts 658import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData'; 659 660let fileUriDetails : Record<string, string> = { 661 'attr1': 'value1', 662 'attr2': 'value2', 663} 664let fileUri : uniformDataStruct.FileUri = { 665 uniformDataType : 'general.file-uri', 666 oriUri : 'file://data/image/1.png', 667 fileType : 'general.image', 668 details : fileUriDetails, 669} 670let formDetails : Record<string, string> = { 671 'attr1': 'value1', 672 'attr2': 'value2', 673} 674let form : uniformDataStruct.Form = { 675 uniformDataType : 'openharmony.form', 676 formId : 1, 677 formName : 'form', 678 bundleName : 'com.xx.app', 679 abilityName : 'ability', 680 module : 'module', 681 details : formDetails, 682} 683 684let unifiedData = new unifiedDataChannel.UnifiedData(); 685let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form); 686record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri); 687unifiedData.addRecord(record); 688 689let records = unifiedData.getRecords(); 690for (let i = 0; i < records.length; i++) { 691 let unifiedDataRecord = records[i] as unifiedDataChannel.UnifiedRecord; 692 let entries : Record<string, unifiedDataChannel.ValueType> = unifiedDataRecord.getEntries(); 693 let formRead : uniformDataStruct.Form = entries[uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM] as uniformDataStruct.Form 694 if (formRead != undefined) { 695 console.info(`formName: ${formRead.formName}`); 696 } 697} 698``` 699 700### getTypes<sup>15+</sup> 701 702getTypes(): Array\<string\> 703 704Obtains 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. 705 706**Atomic service API**: This API can be used in atomic services since API version 15. 707 708**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 709 710**Return value** 711 712| Type | Description | 713| ---------------------------------------- |-------------------------| 714| Array\<string\> | Array of [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype)s obtained.| 715 716**Example** 717 718```ts 719import { uniformDataStruct, uniformTypeDescriptor } from '@kit.ArkData'; 720 721let fileUriDetails : Record<string, string> = { 722 'attr1': 'value1', 723 'attr2': 'value2', 724} 725let fileUri : uniformDataStruct.FileUri = { 726 uniformDataType : 'general.file-uri', 727 oriUri : 'file://data/image/1.png', 728 fileType : 'general.image', 729 details : fileUriDetails, 730} 731let formDetails : Record<string, string> = { 732 'attr1': 'value1', 733 'attr2': 'value2', 734} 735let form : uniformDataStruct.Form = { 736 uniformDataType : 'openharmony.form', 737 formId : 1, 738 formName : 'form', 739 bundleName : 'com.xx.app', 740 abilityName : 'ability', 741 module : 'module', 742 details : formDetails, 743} 744 745let unifiedData = new unifiedDataChannel.UnifiedData(); 746let record = new unifiedDataChannel.UnifiedRecord(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM, form); 747record.addEntry(uniformTypeDescriptor.UniformDataType.FILE_URI, fileUri); 748unifiedData.addRecord(record); 749 750let records = unifiedData.getRecords(); 751for (let i = 0; i < records.length; i++) { 752 let unifiedDataRecord = records[i] as unifiedDataChannel.UnifiedRecord; 753 let types : Array<string> = unifiedDataRecord.getTypes(); 754 if (types.includes(uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM)) { 755 console.info(`types include: ${uniformTypeDescriptor.UniformDataType.OPENHARMONY_FORM}`); 756 } 757} 758``` 759 760## Text 761 762Represents 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. 763 764**Atomic service API**: This API can be used in atomic services since API version 11. 765 766**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 767 768| Name| Type| Read-Only| Optional| Description| 769| -------- | -------- | -------- | -------- | -------- | 770| 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.| 771 772**Example** 773 774```ts 775let text = new unifiedDataChannel.Text(); 776text.details = { 777 title: 'MyTitle', 778 content: 'this is content', 779}; 780let unifiedData = new unifiedDataChannel.UnifiedData(text); 781``` 782 783## PlainText 784 785Represents the plaintext data. It is a child class of [Text](#text) and is used to describe plaintext data. 786 787**Atomic service API**: This API can be used in atomic services since API version 11. 788 789**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 790 791| Name| Type| Read-Only| Optional| Description| 792| -------- | -------- | -------- | -------- | -------- | 793| textContent | string | No| No| Plaintext content. | 794| abstract | string | No| Yes| Text abstract. This parameter is optional. The default value is an empty string.| 795 796**Example** 797 798```ts 799let text = new unifiedDataChannel.PlainText(); 800text.textContent = 'this is textContent'; 801text.abstract = 'this is abstract'; 802``` 803 804## Hyperlink 805 806Represents hyperlink data. It is a child class of [Text](#text) and is used to describe data of the hyperlink type. 807 808**Atomic service API**: This API can be used in atomic services since API version 11. 809 810**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 811 812| Name| Type| Read-Only| Optional| Description| 813| -------- | -------- | -------- | -------- | -------- | 814| url | string | No| No| URL. | 815| description | string | No| Yes| Description of the linked content. This parameter is optional. The default value is an empty string.| 816 817**Example** 818 819```ts 820let link = new unifiedDataChannel.Hyperlink(); 821link.url = 'www.XXX.com'; 822link.description = 'this is description'; 823``` 824 825## HTML 826 827Represents the HTML data. It is a child class of [Text](#text) and is used to describe HTML data. 828 829**Atomic service API**: This API can be used in atomic services since API version 11. 830 831**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 832 833| Name| Type| Read-Only| Optional| Description| 834| -------- | -------- | -------- | -------- | -------- | 835| htmlContent | string | No| No| Content in HTML format. | 836| plainContent | string | No| Yes| Plaintext without HTML tags. This parameter is optional. The default value is an empty string.| 837 838**Example** 839 840```ts 841let html = new unifiedDataChannel.HTML(); 842html.htmlContent = '<div><p>Title</p></div>'; 843html.plainContent = 'this is plainContent'; 844``` 845 846## File 847 848Represents 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. 849 850**Atomic service API**: This API can be used in atomic services since API version 11. 851 852**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 853 854| Name| Type| Read-Only| Optional| Description| 855| -------- | -------- | -------- | -------- | -------- | 856| 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.| 857| uri | string | No| No| URI of the file data. | 858 859**Example** 860 861```ts 862let file = new unifiedDataChannel.File(); 863file.details = { 864 name: 'test', 865 type: 'txt', 866}; 867file.uri = 'schema://com.samples.test/files/test.txt'; 868``` 869 870## Image 871 872Represents the image data. It is a child class of [File](#file) and is used to describe images. 873 874**Atomic service API**: This API can be used in atomic services since API version 11. 875 876**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 877 878| Name| Type| Read-Only| Optional| Description| 879| -------- | -------- | -------- | -------- | -------- | 880| imageUri | string | No| No| URI of the image.| 881 882**Example** 883 884```ts 885let image = new unifiedDataChannel.Image(); 886image.imageUri = 'schema://com.samples.test/files/test.jpg'; 887``` 888 889## Video 890 891Represents video data. It is a child class of [File](#file) and is used to describe a video file. 892 893**Atomic service API**: This API can be used in atomic services since API version 11. 894 895**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 896 897| Name| Type| Read-Only| Optional| Description| 898| -------- | -------- | -------- | -------- | -------- | 899| videoUri | string | No| No| URI of the video file.| 900 901**Example** 902 903```ts 904let video = new unifiedDataChannel.Video(); 905video.videoUri = 'schema://com.samples.test/files/test.mp4'; 906``` 907 908## Audio 909 910Represents audio data. It is a child class of [File](#file) and is used to describe an audio file. 911 912**Atomic service API**: This API can be used in atomic services since API version 11. 913 914**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 915 916| Name| Type| Read-Only| Optional| Description| 917| -------- | -------- | -------- | -------- | -------- | 918| audioUri | string | No| No| Audio data URI.| 919 920**Example** 921 922```ts 923let audio = new unifiedDataChannel.Audio(); 924audio.audioUri = 'schema://com.samples.test/files/test.mp3'; 925``` 926 927## Folder 928 929Represents the folder data. It is a child class of [File](#file) and is used to describe a folder. 930 931**Atomic service API**: This API can be used in atomic services since API version 11. 932 933**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 934 935| Name| Type| Read-Only| Optional| Description| 936| -------- | -------- | -------- | -------- | -------- | 937| folderUri | string | No| No| URI of the folder.| 938 939**Example** 940 941```ts 942let folder = new unifiedDataChannel.Folder(); 943folder.folderUri = 'schema://com.samples.test/files/folder/'; 944``` 945 946## SystemDefinedRecord 947 948Represents 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. 949 950**Atomic service API**: This API can be used in atomic services since API version 11. 951 952**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 953 954| Name| Type| Read-Only| Optional| Description| 955| -------- | -------- | -------- | -------- | -------- | 956| 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.| 957 958**Example** 959 960```ts 961let sdr = new unifiedDataChannel.SystemDefinedRecord(); 962let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 963sdr.details = { 964 title: 'recordTitle', 965 version: 1, 966 content: u8Array, 967}; 968let unifiedData = new unifiedDataChannel.UnifiedData(sdr); 969``` 970 971## SystemDefinedForm 972 973Represents the service widget data defined by the system. It is a child class of [SystemDefinedRecord](#systemdefinedrecord). 974 975**Atomic service API**: This API can be used in atomic services since API version 11. 976 977**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 978 979| Name| Type| Read-Only| Optional| Description| 980| -------- | -------- | -------- | -------- | -------- | 981| formId | number | No| No| Service widget ID. | 982| formName | string | No| No| Widget name. | 983| bundleName | string | No| No| Name of the bundle to which the widget belongs. | 984| abilityName | string | No| No| Ability name corresponding to the widget.| 985| module | string | No| No| Name of the module to which the widget belongs. | 986 987**Example** 988 989```ts 990let form = new unifiedDataChannel.SystemDefinedForm(); 991form.formId = 123456; 992form.formName = 'MyFormName'; 993form.bundleName = 'MyBundleName'; 994form.abilityName = 'MyAbilityName'; 995form.module = 'MyModule'; 996let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 997form.details = { 998 formKey1: 123, 999 formKey2: 'formValue', 1000 formKey3: u8Array, 1001}; 1002let unifiedData = new unifiedDataChannel.UnifiedData(form); 1003``` 1004 1005## SystemDefinedAppItem 1006 1007Represents the data of the home screen icon defined by the system. It is a child class of [SystemDefinedRecord](#systemdefinedrecord). 1008 1009**Atomic service API**: This API can be used in atomic services since API version 11. 1010 1011**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1012 1013| Name| Type| Read-Only| Optional| Description| 1014| -------- | -------- | -------- | -------- | -------- | 1015| appId | string | No| No| ID of the application, for which the icon is used. | 1016| appName | string | No| No| Name of the application, for which the icon is used. | 1017| appIconId | string | No| No| Image ID of the icon. | 1018| appLabelId | string | No| No| Label ID corresponding to the icon name. | 1019| bundleName | string | No| No| Bundle name corresponding to the icon.| 1020| abilityName | string | No| No| Application ability name corresponding to the icon.| 1021 1022**Example** 1023 1024```ts 1025let appItem = new unifiedDataChannel.SystemDefinedAppItem(); 1026appItem.appId = 'MyAppId'; 1027appItem.appName = 'MyAppName'; 1028appItem.appIconId = 'MyAppIconId'; 1029appItem.appLabelId = 'MyAppLabelId'; 1030appItem.bundleName = 'MyBundleName'; 1031appItem.abilityName = 'MyAbilityName'; 1032let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 1033appItem.details = { 1034 appItemKey1: 123, 1035 appItemKey2: 'appItemValue', 1036 appItemKey3: u8Array, 1037}; 1038let unifiedData = new unifiedDataChannel.UnifiedData(appItem); 1039``` 1040 1041## SystemDefinedPixelMap 1042 1043Represents 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. 1044 1045**Atomic service API**: This API can be used in atomic services since API version 11. 1046 1047**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1048 1049| Name| Type| Read-Only| Optional| Description| 1050| -------- | -------- | -------- | -------- | -------- | 1051| rawData | Uint8Array | No| No| Binary data of the **PixelMap** object.| 1052 1053**Example** 1054 1055```ts 1056import { image } from '@kit.ImageKit'; // Module where the PixelMap class is defined. 1057import { unifiedDataChannel, uniformTypeDescriptor } from '@kit.ArkData'; 1058import { BusinessError } from '@kit.BasicServicesKit'; 1059 1060const color = new ArrayBuffer(96); // Create a PixelMap object. 1061let opts: image.InitializationOptions = { 1062 editable: true, pixelFormat: 3, size: { 1063 height: 4, width: 6 1064 } 1065} 1066image.createPixelMap(color, opts, (error, pixelmap) => { 1067 if (error) { 1068 console.error('Failed to create pixelmap.'); 1069 } else { 1070 console.info('Succeeded in creating pixelmap.'); 1071 let arrayBuf = new ArrayBuffer(pixelmap.getPixelBytesNumber()); 1072 pixelmap.readPixelsToBuffer(arrayBuf); 1073 let u8Array = new Uint8Array(arrayBuf); 1074 let sdpixel = new unifiedDataChannel.SystemDefinedPixelMap(); 1075 sdpixel.rawData = u8Array; 1076 let unifiedData = new unifiedDataChannel.UnifiedData(sdpixel); 1077 1078 // Read the record of the pixelMap type from unifiedData. 1079 let records = unifiedData.getRecords(); 1080 for (let i = 0; i < records.length; i++) { 1081 if (records[i].getType() === uniformTypeDescriptor.UniformDataType.OPENHARMONY_PIXEL_MAP) { 1082 let pixelmapRecord = records[i] as unifiedDataChannel.SystemDefinedPixelMap; 1083 let newArraybuf = pixelmapRecord.rawData.buffer; 1084 pixelmap.writeBufferToPixels(newArraybuf).then(() => { 1085 console.info('Succeeded in writing data from buffer to a pixelMap'); 1086 }).catch((error: BusinessError) => { 1087 console.error(`Failed to write data from a buffer to a PixelMap. code is ${error.code}, message is ${error.message}`); 1088 }) 1089 } 1090 } 1091 } 1092}) 1093``` 1094 1095## ApplicationDefinedRecord 1096 1097Represents 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. 1098 1099**Atomic service API**: This API can be used in atomic services since API version 11. 1100 1101**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1102 1103| Name| Type| Read-Only| Optional| Description| 1104| -------- | -------- | -------- | -------- | -------- | 1105| applicationDefinedType | string | No| No| Application's custom data type identifier, which must start with **ApplicationDefined**.| 1106| rawData | Uint8Array | No| No| Binary data of the custom data type. | 1107 1108**Example** 1109 1110```ts 1111let record = new unifiedDataChannel.ApplicationDefinedRecord(); 1112let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 1113record.applicationDefinedType = 'ApplicationDefinedType'; 1114record.rawData = u8Array; 1115let unifiedData = new unifiedDataChannel.UnifiedData(record); 1116``` 1117 1118## Intention 1119 1120Enumerates the data channel types supported by the UDMF. It is used to identify different service scenarios, to which the UDMF data channels apply. 1121 1122**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1123 1124| Name | Value | Description | 1125|----------|-----------|---------| 1126| DATA_HUB | 'DataHub' | Public data channel.<br>**Atomic service API**: This API can be used in atomic services since API version 11.| 1127| 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.| 1128 1129## Options 1130 1131type Options = { intention?: Intention; key?: string; } 1132 1133Defines the data operation performed by the UDMF. It includes two optional parameters: **intention** and **key**. The two parameters have no default value, and can be left unspecified. For details, see the parameter description of the specific API. 1134 1135**Atomic service API**: This API can be used in atomic services since API version 11. 1136 1137**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1138 1139| Name | Type | Mandatory| Description | 1140| --------- | ----------------------- | ---- | ------------------------------------------------------------ | 1141| intention | [Intention](#intention) | No | Type of the data channel related to the data operation. | 1142| 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.| 1143 1144## FileConflictOptions<sup>15+</sup> 1145 1146Enumerates the options for resolving file copy conflicts. 1147 1148**Atomic service API**: This API can be used in atomic services since API version 15. 1149 1150**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1151 1152| Name | Value | Description | 1153| --------- | ---- |----------------| 1154| OVERWRITE | 0 | Overwrite the file with the same name in the destination directory.| 1155| SKIP | 1 | Skip the file if there is a file with the same name in the destination directory.| 1156 1157## ProgressIndicator<sup>15+</sup> 1158 1159Enumerates the progress indicator options. 1160 1161**Atomic service API**: This API can be used in atomic services since API version 15. 1162 1163**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1164 1165| Name | Value | Description | 1166| ------- | ---- |------------------------------------| 1167| NONE | 0 | Do not use the default progress indicator. | 1168| DEFAULT | 1 | Use the default progress indicator. If data is obtained within 500 ms, the default progress bar is not started.| 1169 1170## ListenerStatus<sup>15+</sup> 1171 1172Enumerates the status codes returned when data is obtained from the UDMF. 1173 1174**Atomic service API**: This API can be used in atomic services since API version 15. 1175 1176**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1177 1178| Name | Value | Description | 1179| ------- |-----|----------------------------------------------| 1180| FINISHED | 0 | The task is completed. | 1181| PROCESSING | 1 | The task is being processed. | 1182| CANCELED | 2 | The task is canceled. | 1183| INNER_ERROR | 200 | An internal error occurs. | 1184| INVALID_PARAMETERS | 201 | [GetDataParams](#getdataparams15) contains invalid parameters.| 1185| DATA_NOT_FOUND | 202 | No data is obtained. | 1186| SYNC_FAILED | 203 | Failed to sync data. | 1187| COPY_FILE_FAILED | 204 | Failed to copy data. | 1188 1189## ProgressInfo<sup>15+</sup> 1190 1191Represents the progress information. 1192 1193**Atomic service API**: This API can be used in atomic services since API version 15. 1194 1195**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1196 1197| Name | Type | Readable| Writable| Description | 1198| -------- |-------------------------------------| ---- | ---- |----------------------------------------------------------------| 1199| 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.| 1200| status | [ListenerStatus](#listenerstatus15) | Yes | No | Status code of the drag task reported by the system. | 1201 1202## DataProgressListener<sup>15+</sup> 1203 1204type DataProgressListener = (progressInfo: ProgressInfo, data: UnifiedData | null) => void 1205 1206Defines the callback used to return the data retrieval progress information and data obtained. 1207 1208**Atomic service API**: This API can be used in atomic services since API version 15. 1209 1210**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1211 1212**Parameters** 1213 1214| Name | Type | Mandatory | Description | 1215|----------|-------------------------------|-------|--------------| 1216| progressInfo| [ProgressInfo](#progressinfo15) | Yes | Progress information to report.| 1217| data | [UnifiedData](#unifieddata) \| null | Yes | Data obtained when the progress reaches 100. If the progress does not reach 100, **null** is returned.| 1218 1219## GetDataParams<sup>15+</sup> 1220 1221Represents the parameters for obtaining data from UDMF, including the destination directory, option for resolving file conflicts, and progress indicator type. 1222 1223**Atomic service API**: This API can be used in atomic services since API version 15. 1224 1225 1226**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1227 1228**Parameters** 1229 1230| Name | Type | Mandatory| Description | 1231|----------------------|-------------------------------------------------| ---- |----------------------------------------------------------------------------------------------------------------------------------------------------| 1232| progressIndicator | [ProgressIndicator](#progressindicator15) | Yes| Progress indicator options. You can use the default progress indicator as required. | 1233| dataProgressListener | [DataProgressListener](#dataprogresslistener15) | Yes| Callback used to return the data retrieval progress and data obtained. | 1234| 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.| 1235| fileConflictOptions | [FileConflictOptions](#fileconflictoptions15) | No | Option for resolving file copy conflicts. The default value is **OVERWRITE**. | 1236 1237## unifiedDataChannel.insertData 1238 1239insertData(options: Options, data: UnifiedData, callback: AsyncCallback<string>): void 1240 1241Inserts data to the UDMF public data channel. This API uses an asynchronous callback to return the unique identifier of the data inserted. 1242 1243**Atomic service API**: This API can be used in atomic services since API version 11. 1244 1245**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1246 1247**Parameters** 1248 1249| Name | Type | Mandatory| Description | 1250|----------|----------------------------|----|------------------------------| 1251| options | [Options](#options) | Yes | Configuration parameters. Only the **intention** is required. | 1252| data | [UnifiedData](#unifieddata) | Yes | Data to insert. | 1253| callback | AsyncCallback<string> | Yes | Callback used to return the key (unique identifier) of the data inserted.| 1254 1255**Error codes** 1256 1257For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1258 1259| **ID**| **Error Message** | 1260| ------------ | ------------------------------------------- | 1261| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1262 1263**Example** 1264 1265```ts 1266import { unifiedDataChannel } from '@kit.ArkData'; 1267import { BusinessError } from '@kit.BasicServicesKit'; 1268 1269let plainText = new unifiedDataChannel.PlainText(); 1270plainText.textContent = 'hello world!'; 1271let unifiedData = new unifiedDataChannel.UnifiedData(plainText); 1272 1273let options: unifiedDataChannel.Options = { 1274 intention: unifiedDataChannel.Intention.DATA_HUB 1275} 1276try { 1277 unifiedDataChannel.insertData(options, unifiedData, (err, data) => { 1278 if (err === undefined) { 1279 console.info(`Succeeded in inserting data. key = ${data}`); 1280 } else { 1281 console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `); 1282 } 1283 }); 1284 } catch (e) { 1285 let error: BusinessError = e as BusinessError; 1286 console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `); 1287} 1288 1289``` 1290 1291## unifiedDataChannel.insertData 1292 1293insertData(options: Options, data: UnifiedData): Promise<string> 1294 1295Inserts data to the UDMF public data channel. This API uses a promise to return the unique identifier of the data inserted. 1296 1297**Atomic service API**: This API can be used in atomic services since API version 11. 1298 1299**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1300 1301**Parameters** 1302 1303| Name | Type | Mandatory| Description | 1304|---------|-----------------------------|----|-----------------------| 1305| options | [Options](#options) | Yes | Configuration parameters. Only the **intention** is required.| 1306| data | [UnifiedData](#unifieddata) | Yes | Data to insert. | 1307 1308**Return value** 1309 1310| Type | Description | 1311|-----------------------|-----------------------------------| 1312| Promise<string> | Promise used to return the key of the data inserted.| 1313 1314**Error codes** 1315 1316For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1317 1318| **ID**| **Error Message** | 1319| ------------ | ------------------------------------------- | 1320| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1321 1322**Example** 1323 1324```ts 1325import { unifiedDataChannel } from '@kit.ArkData'; 1326import { BusinessError } from '@kit.BasicServicesKit'; 1327 1328let plainText = new unifiedDataChannel.PlainText(); 1329plainText.textContent = 'hello world!'; 1330let unifiedData = new unifiedDataChannel.UnifiedData(plainText); 1331 1332let options: unifiedDataChannel.Options = { 1333 intention: unifiedDataChannel.Intention.DATA_HUB 1334} 1335try { 1336 unifiedDataChannel.insertData(options, unifiedData).then((data) => { 1337 console.info(`Succeeded in inserting data. key = ${data}`); 1338 }).catch((err: BusinessError) => { 1339 console.error(`Failed to insert data. code is ${err.code},message is ${err.message} `); 1340 }); 1341} catch (e) { 1342 let error: BusinessError = e as BusinessError; 1343 console.error(`Insert data throws an exception. code is ${error.code},message is ${error.message} `); 1344} 1345``` 1346 1347## unifiedDataChannel.updateData 1348 1349updateData(options: Options, data: UnifiedData, callback: AsyncCallback<void>): void 1350 1351Updates the data in the UDMF public data channel. This API uses an asynchronous callback to return the result. 1352 1353**Atomic service API**: This API can be used in atomic services since API version 11. 1354 1355**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1356 1357**Parameters** 1358 1359| Name | Type | Mandatory| Description | 1360|----------|-----------------------------|----|-------------------------------------| 1361| options | [Options](#options) | Yes | Configuration parameters. Only the value of **key** is required. | 1362| data | [UnifiedData](#unifieddata) | Yes | New data. | 1363| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the data is updated successfully, **err** is **undefined**. Otherwise, **err** is an error object.| 1364 1365**Error codes** 1366 1367For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1368 1369| **ID**| **Error Message** | 1370| ------------ | ------------------------------------------- | 1371| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1372 1373**Example** 1374 1375```ts 1376import { unifiedDataChannel } from '@kit.ArkData'; 1377import { BusinessError } from '@kit.BasicServicesKit'; 1378 1379let plainText = new unifiedDataChannel.PlainText(); 1380plainText.textContent = 'hello world!'; 1381let unifiedData = new unifiedDataChannel.UnifiedData(plainText); 1382 1383let options: unifiedDataChannel.Options = { 1384 key: 'udmf://DataHub/com.ohos.test/0123456789' 1385}; 1386 1387try { 1388 unifiedDataChannel.updateData(options, unifiedData, (err) => { 1389 if (err === undefined) { 1390 console.info('Succeeded in updating data.'); 1391 } else { 1392 console.error(`Failed to update data. code is ${err.code},message is ${err.message} `); 1393 } 1394 }); 1395} catch (e) { 1396 let error: BusinessError = e as BusinessError; 1397 console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `); 1398} 1399``` 1400 1401## unifiedDataChannel.updateData 1402 1403updateData(options: Options, data: UnifiedData): Promise<void> 1404 1405Updates the data in the UDMF public data channel. This API uses a promise to return the result. 1406 1407**Atomic service API**: This API can be used in atomic services since API version 11. 1408 1409**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1410 1411**Parameters** 1412 1413| Name | Type | Mandatory| Description | 1414|---------|-----------------------------|----|-----------------| 1415| options | [Options](#options) | Yes | Configuration parameters. Only the value of **key** is required.| 1416| data | [UnifiedData](#unifieddata) | Yes | New data. | 1417 1418**Return value** 1419 1420| Type | Description | 1421|---------------------|----------------------------| 1422| Promise<void> | Promise that returns no value.| 1423 1424**Error codes** 1425 1426For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1427 1428| **ID**| **Error Message** | 1429| ------------ | ------------------------------------------- | 1430| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1431 1432**Example** 1433 1434```ts 1435import { unifiedDataChannel } from '@kit.ArkData'; 1436import { BusinessError } from '@kit.BasicServicesKit'; 1437 1438let plainText = new unifiedDataChannel.PlainText(); 1439plainText.textContent = 'hello world!'; 1440let unifiedData = new unifiedDataChannel.UnifiedData(plainText); 1441 1442let options: unifiedDataChannel.Options = { 1443 key: 'udmf://DataHub/com.ohos.test/0123456789' 1444}; 1445 1446try { 1447 unifiedDataChannel.updateData(options, unifiedData).then(() => { 1448 console.info('Succeeded in updating data.'); 1449 }).catch((err: BusinessError) => { 1450 console.error(`Failed to update data. code is ${err.code},message is ${err.message} `); 1451 }); 1452} catch (e) { 1453 let error: BusinessError = e as BusinessError; 1454 console.error(`Update data throws an exception. code is ${error.code},message is ${error.message} `); 1455} 1456``` 1457 1458## unifiedDataChannel.queryData 1459 1460queryData(options: Options, callback: AsyncCallback<Array<UnifiedData>>): void 1461 1462Queries data in the UDMF public data channel. This API uses an asynchronous callback to return the result. 1463 1464**Atomic service API**: This API can be used in atomic services since API version 11. 1465 1466**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1467 1468**Parameters** 1469 1470| Name | Type | Mandatory| Description | 1471|----------|---------------------------------------------------------------|----|------------------------------------------------------------------------------------------------------------------------------------------------------------------| 1472| options | [Options](#options) | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in. | 1473| callback | AsyncCallback<Array<[UnifiedData](#unifieddata)>> | 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.| 1474 1475**Error codes** 1476 1477For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1478 1479| **ID**| **Error Message** | 1480| ------------ | ------------------------------------------- | 1481| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1482 1483**Example** 1484 1485```ts 1486import { unifiedDataChannel } from '@kit.ArkData'; 1487import { uniformTypeDescriptor } from '@kit.ArkData'; 1488import { BusinessError } from '@kit.BasicServicesKit'; 1489 1490let options: unifiedDataChannel.Options = { 1491 intention: unifiedDataChannel.Intention.DATA_HUB 1492}; 1493 1494try { 1495 unifiedDataChannel.queryData(options, (err, data) => { 1496 if (err === undefined) { 1497 console.info(`Succeeded in querying data. size = ${data.length}`); 1498 for (let i = 0; i < data.length; i++) { 1499 let records = data[i].getRecords(); 1500 for (let j = 0; j < records.length; j++) { 1501 if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { 1502 let text = records[j] as unifiedDataChannel.PlainText; 1503 console.info(`${i + 1}.${text.textContent}`); 1504 } 1505 } 1506 } 1507 } else { 1508 console.error(`Failed to query data. code is ${err.code},message is ${err.message} `); 1509 } 1510 }); 1511} catch (e) { 1512 let error: BusinessError = e as BusinessError; 1513 console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `); 1514} 1515``` 1516 1517## unifiedDataChannel.queryData 1518 1519queryData(options: Options): Promise<Array<UnifiedData>> 1520 1521Queries data in the UDMF public data channel. This API uses a promise to return the result. 1522 1523**Atomic service API**: This API can be used in atomic services since API version 11. 1524 1525**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1526 1527**Parameters** 1528 1529| Name | Type | Mandatory| Description | 1530|---------|---------------------|----|-----------------------------------------------| 1531| options | [Options](#options) | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in.| 1532 1533**Return value** 1534 1535| Type | Description | 1536|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------| 1537| Promise<Array<[UnifiedData](#unifieddata)>> | 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.| 1538 1539**Error codes** 1540 1541For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1542 1543| **ID**| **Error Message** | 1544| ------------ | ------------------------------------------- | 1545| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1546 1547**Example** 1548 1549```ts 1550import { unifiedDataChannel } from '@kit.ArkData'; 1551import { uniformTypeDescriptor } from '@kit.ArkData'; 1552import { BusinessError } from '@kit.BasicServicesKit'; 1553 1554let options: unifiedDataChannel.Options = { 1555 key: 'udmf://DataHub/com.ohos.test/0123456789' 1556}; 1557 1558try { 1559 unifiedDataChannel.queryData(options).then((data) => { 1560 console.info(`Succeeded in querying data. size = ${data.length}`); 1561 for (let i = 0; i < data.length; i++) { 1562 let records = data[i].getRecords(); 1563 for (let j = 0; j < records.length; j++) { 1564 if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { 1565 let text = records[j] as unifiedDataChannel.PlainText; 1566 console.info(`${i + 1}.${text.textContent}`); 1567 } 1568 } 1569 } 1570 }).catch((err: BusinessError) => { 1571 console.error(`Failed to query data. code is ${err.code},message is ${err.message} `); 1572 }); 1573} catch (e) { 1574 let error: BusinessError = e as BusinessError; 1575 console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `); 1576} 1577``` 1578 1579## unifiedDataChannel.deleteData 1580 1581deleteData(options: Options, callback: AsyncCallback<Array<UnifiedData>>): void 1582 1583Deletes data from the UDMF public data channel. This API uses an asynchronous callback to return the result. 1584 1585**Atomic service API**: This API can be used in atomic services since API version 11. 1586 1587**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1588 1589**Parameters** 1590 1591| Name | Type | Mandatory| Description | 1592|----------|---------------------------------------------------------------|----|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 1593| options | [Options](#options) | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in. | 1594| callback | AsyncCallback<Array<[UnifiedData](#unifieddata)>> | 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.| 1595 1596**Error codes** 1597 1598For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1599 1600| **ID**| **Error Message** | 1601| ------------ | ------------------------------------------- | 1602| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1603 1604**Example** 1605 1606```ts 1607import { unifiedDataChannel } from '@kit.ArkData'; 1608import { uniformTypeDescriptor } from '@kit.ArkData'; 1609import { BusinessError } from '@kit.BasicServicesKit'; 1610 1611let options: unifiedDataChannel.Options = { 1612 intention: unifiedDataChannel.Intention.DATA_HUB 1613}; 1614 1615try { 1616 unifiedDataChannel.deleteData(options, (err, data) => { 1617 if (err === undefined) { 1618 console.info(`Succeeded in deleting data. size = ${data.length}`); 1619 for (let i = 0; i < data.length; i++) { 1620 let records = data[i].getRecords(); 1621 for (let j = 0; j < records.length; j++) { 1622 if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { 1623 let text = records[j] as unifiedDataChannel.PlainText; 1624 console.info(`${i + 1}.${text.textContent}`); 1625 } 1626 } 1627 } 1628 } else { 1629 console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `); 1630 } 1631 }); 1632} catch (e) { 1633 let error: BusinessError = e as BusinessError; 1634 console.error(`Delete data throws an exception. code is ${error.code},message is ${error.message} `); 1635} 1636``` 1637 1638## unifiedDataChannel.deleteData 1639 1640deleteData(options: Options): Promise<Array<UnifiedData>> 1641 1642Deletes data from the UDMF public data channel. This API uses a promise to return the result. 1643 1644**Atomic service API**: This API can be used in atomic services since API version 11. 1645 1646**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1647 1648**Parameters** 1649 1650| Name | Type | Mandatory| Description | 1651|---------|---------------------|----|--------| 1652| options | [Options](#options) | Yes | Configuration parameters. Both the **key** and **intention** are optional, and the return value varies depending on the parameters passed in.| 1653 1654**Return value** 1655 1656| Type | Description | 1657|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| 1658| Promise<Array<[UnifiedData](#unifieddata)>> | 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.| 1659 1660**Error codes** 1661 1662For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1663 1664| **ID**| **Error Message** | 1665| ------------ | ------------------------------------------- | 1666| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameters types. | 1667 1668**Example** 1669 1670```ts 1671import { unifiedDataChannel } from '@kit.ArkData'; 1672import { uniformTypeDescriptor } from '@kit.ArkData'; 1673import { BusinessError } from '@kit.BasicServicesKit'; 1674 1675let options: unifiedDataChannel.Options = { 1676 key: 'udmf://DataHub/com.ohos.test/0123456789' 1677}; 1678 1679try { 1680 unifiedDataChannel.deleteData(options).then((data) => { 1681 console.info(`Succeeded in deleting data. size = ${data.length}`); 1682 for (let i = 0; i < data.length; i++) { 1683 let records = data[i].getRecords(); 1684 for (let j = 0; j < records.length; j++) { 1685 if (records[j].getType() === uniformTypeDescriptor.UniformDataType.PLAIN_TEXT) { 1686 let text = records[j] as unifiedDataChannel.PlainText; 1687 console.info(`${i + 1}.${text.textContent}`); 1688 } 1689 } 1690 } 1691 }).catch((err: BusinessError) => { 1692 console.error(`Failed to delete data. code is ${err.code},message is ${err.message} `); 1693 }); 1694} catch (e) { 1695 let error: BusinessError = e as BusinessError; 1696 console.error(`Query data throws an exception. code is ${error.code},message is ${error.message} `); 1697} 1698``` 1699 1700## unifiedDataChannel.setAppShareOptions<sup>14+</sup> 1701 1702setAppShareOptions(intention: Intention, shareOptions: ShareOptions): void 1703 1704Sets [ShareOptions](#shareoptions12) for the application data. Currently, only the drag-and-drop data channel is supported. 1705 1706**Required permissions**: ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION 1707 1708**Model restriction**: This API can be used only in the stage model. 1709 1710**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1711 1712**Parameters** 1713 1714| Name | Type | Mandatory| Description | 1715|----------|----------------------------|----|------------------------------| 1716| intention | [Intention](#intention) | Yes | Type of the data channel. Currently, only the data channel of the **DRAG** type is supported.| 1717| shareOptions | [ShareOptions](#shareoptions12) | Yes | Usage scope of the [UnifiedData](#unifieddata).| 1718 1719**Error codes** 1720 1721For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [UDMF Error Codes](errorcode-udmf.md). 1722 1723| **ID**| **Error Message** | 1724| ------------ | ------------------------------------------------------------ | 1725| 201 | Permission denied. Interface caller does not have permission "ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION". | 1726| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1727| 20400001 | Settings already exist. | 1728 1729**Example** 1730 1731```ts 1732import { BusinessError } from '@kit.BasicServicesKit'; 1733try { 1734 unifiedDataChannel.setAppShareOptions(unifiedDataChannel.Intention.DRAG, unifiedDataChannel.ShareOptions.IN_APP); 1735 console.info(`[UDMF]setAppShareOptions success. `); 1736}catch (e){ 1737 let error: BusinessError = e as BusinessError; 1738 console.error(`[UDMF]setAppShareOptions throws an exception. code is ${error.code},message is ${error.message} `); 1739} 1740``` 1741 1742## unifiedDataChannel.removeAppShareOptions<sup>14+</sup> 1743 1744removeAppShareOptions(intention: Intention): void 1745 1746Removes the **ShareOptions** set by [setAppShareOptions](#unifieddatachannelsetappshareoptions14). 1747 1748**Required permissions**: ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION 1749 1750**Model restriction**: This API can be used only in the stage model. 1751 1752**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 1753 1754**Parameters** 1755 1756| Name | Type | Mandatory| Description | 1757| --------- | ----------------------- | ---- | ------------------------------------------------------------ | 1758| intention | [Intention](#intention) | Yes | Type of the data channel. Currently, only the data channel of the **DRAG** type is supported.| 1759 1760**Error codes** 1761 1762For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 1763 1764| **ID**| **Error Message** | 1765| ------------ | ------------------------------------------------------------ | 1766| 201 | Permission denied. Interface caller does not have permission "ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION". | 1767| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1768 1769**Example** 1770 1771```ts 1772import { BusinessError } from '@kit.BasicServicesKit'; 1773try { 1774 unifiedDataChannel.removeAppShareOptions(unifiedDataChannel.Intention.DRAG); 1775 console.info(`[UDMF]removeAppShareOptions success. `); 1776}catch (e){ 1777 let error: BusinessError = e as BusinessError; 1778 console.error(`[UDMF]removeAppShareOptions throws an exception. code is ${error.code},message is ${error.message} `); 1779} 1780``` 1781<!--no_check-->