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