• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# DataUriUtils Module
2
3> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
4> 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.
5
6## Modules to Import
7
8```js
9import dataUriUtils from '@ohos.ability.dataUriUtils';
10```
11
12## dataUriUtils.getId
13
14getId(uri: string): number
15
16Obtains the ID attached to the end of a given URI.
17
18**System capability**: SystemCapability.Ability.AbilityRuntime.Core
19
20**Parameters**
21
22| Name| Type  | Mandatory| Description                       |
23| ---- | ------ | ---- | --------------------------- |
24| uri  | string | Yes  | URI object from which the ID is to be obtained.|
25
26**Return value**
27
28| Type  | Description                    |
29| ------ | ------------------------ |
30| number | ID obtained from the URI object.|
31
32**Example**
33
34```js
35dataUriUtils.getId("com.example.dataUriUtils/1221")
36```
37
38## dataUriUtils.attachId
39
40attachId(uri: string, id: number): string
41
42Attaches an ID to the end of a given URI.
43
44**System capability**: SystemCapability.Ability.AbilityRuntime.Core
45
46**Parameters**
47
48| Name| Type  | Mandatory| Description                       |
49| ---- | ------ | ---- | --------------------------- |
50| uri  | string | Yes  | URI object to which an ID is to be attached.|
51| id   | number | Yes  | ID to be attached.           |
52
53**Return value**
54
55| Type  | Description                 |
56| ------ | --------------------- |
57| string | URI object with the ID attached.|
58
59**Example**
60
61```js
62var idint = 1122;
63dataUriUtils.attachId(
64    "com.example.dataUriUtils",
65	idint,
66)
67```
68
69## dataUriUtils.deleteId
70
71deleteId(uri: string): string
72
73Deletes the ID from the end of a given URI.
74
75**System capability**: SystemCapability.Ability.AbilityRuntime.Core
76
77**Parameters**
78
79| Name| Type  | Mandatory| Description                       |
80| ---- | ------ | ---- | --------------------------- |
81| uri  | string | Yes  | URI object from which the ID is to be deleted.|
82
83**Return value**
84
85| Type  | Description               |
86| ------ | ------------------- |
87| string | URI object with the ID deleted.|
88
89**Example**
90
91```js
92dataUriUtils.deleteId("com.example.dataUriUtils/1221")
93```
94
95## dataUriUtils.updateId
96
97updateId(uri: string, id: number): string
98
99Updates the ID in a given URI.
100
101**System capability**: SystemCapability.Ability.AbilityRuntime.Core
102
103**Parameters**
104
105| Name| Type  | Mandatory| Description               |
106| ---- | ------ | ---- | ------------------- |
107| uri  | string | Yes  | URI object to be updated.|
108| id   | number | Yes  | New ID.           |
109
110**Return value**
111
112| Type  | Description           |
113| ------ | --------------- |
114| string | URI object with the new ID.|
115
116**Example**
117
118```js
119var idint = 1122;
120dataUriUtils.updateId(
121    "com.example.dataUriUtils",
122	idint
123)
124```
125