1# @ohos.ability.dataUriUtils (dataUriUtils) 2 3The **DataUriUtils** module provides APIs to process URI objects. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```ts 12import dataUriUtils from '@ohos.ability.dataUriUtils'; 13``` 14 15## dataUriUtils.getId 16 17getId(uri: string): number 18 19Obtains the ID attached to the end of a given URI. 20 21**System capability**: SystemCapability.Ability.AbilityRuntime.Core 22 23**Parameters** 24 25| Name| Type | Mandatory| Description | 26| ---- | ------ | ---- | --------------------------- | 27| uri | string | Yes | Target URI object.| 28 29**Return value** 30 31| Type | Description | 32| ------ | ------------------------ | 33| number | ID obtained.| 34 35**Example** 36 37```ts 38let id = dataUriUtils.getId('com.example.dataUriUtils/1221'); 39``` 40 41 42 43## dataUriUtils.attachId 44 45attachId(uri: string, id: number): string 46 47Attaches an ID to the end of a given URI. 48 49**System capability**: SystemCapability.Ability.AbilityRuntime.Core 50 51**Parameters** 52 53| Name| Type | Mandatory| Description | 54| ---- | ------ | ---- | --------------------------- | 55| uri | string | Yes | Target URI object.| 56| id | number | Yes | ID to be attached. | 57 58**Return value** 59 60| Type | Description | 61| ------ | --------------------- | 62| string | URI object with the ID attached.| 63 64**Example** 65 66```ts 67let id = 1122; 68let uri = dataUriUtils.attachId( 69 'com.example.dataUriUtils', 70 id, 71); 72``` 73 74 75 76## dataUriUtils.deleteId 77 78deleteId(uri: string): string 79 80Deletes the ID from the end of a given URI. 81 82**System capability**: SystemCapability.Ability.AbilityRuntime.Core 83 84**Parameters** 85 86| Name| Type | Mandatory| Description | 87| ---- | ------ | ---- | --------------------------- | 88| uri | string | Yes | URI object from which the ID is to be deleted.| 89 90**Return value** 91 92| Type | Description | 93| ------ | ------------------- | 94| string | URI object with the ID deleted.| 95 96**Example** 97 98```ts 99let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221'); 100``` 101 102 103 104## dataUriUtils.updateId 105 106updateId(uri: string, id: number): string 107 108Updates the ID in a given URI. 109 110**System capability**: SystemCapability.Ability.AbilityRuntime.Core 111 112**Parameters** 113 114| Name| Type | Mandatory| Description | 115| ---- | ------ | ---- | ------------------- | 116| uri | string | Yes | Target URI object.| 117| id | number | Yes | New ID. | 118 119**Return value** 120 121| Type | Description | 122| ------ | --------------- | 123| string | URI object with the new ID.| 124 125**Example** 126 127```ts 128let id = 1122; 129let uri = dataUriUtils.updateId( 130 'com.example.dataUriUtils/1221', 131 id 132); 133``` 134