• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.resourceManager (Resource Management)
2
3The **resourceManager** module provides the resource management functionality. It allows an application to obtain the best matched application resources or system resources based on the specified [configuration](#configuration). For details about the matching rules, see [Resource Matching](../../quick-start/resource-categories-and-access.md#resource-matching).
4
5The configuration includes language, region, screen orientation, mobile country code (MCC), mobile network code (MNC), device capability, and density.
6
7> **NOTE**
8>
9> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
10
11## Modules to Import
12
13```js
14import { resourceManager } from '@kit.LocalizationKit';
15```
16
17## How to Use
18
19Since API version 9, the stage model allows an application to obtain a **ResourceManager** object via **Context**. You do not need to import the module.
20In the FA model, you need to import the module and then call [getResourceManager](#resourcemanagergetresourcemanager) to obtain a **ResourceManager** object.
21For details about how to reference context in the stage model, see [Context in the Stage Model](../../application-models/application-context-stage.md).
22
23```ts
24import { UIAbility } from '@kit.AbilityKit';
25import { window } from '@kit.ArkUI';
26
27export default class EntryAbility extends UIAbility {
28  onWindowStageCreate(windowStage: window.WindowStage) {
29    let context = this.context;
30    let resourceManager = context.resourceManager;
31  }
32}
33```
34
35## resourceManager.getResourceManager
36
37getResourceManager(callback: AsyncCallback<ResourceManager>): void
38
39Obtains the **ResourceManager** object of this application. This API uses an asynchronous callback to return the result.
40
41**System capability**: SystemCapability.Global.ResourceManager
42
43**Model restriction**: This API can be used only in the FA model.
44
45**Parameters**
46
47| Name     | Type                                      | Mandatory  | Description                           |
48| -------- | ---------------------------------------- | ---- | ----------------------------- |
49| callback | [AsyncCallback](#asynccallbackdeprecated)<[ResourceManager](#resourcemanager)> | Yes   | Callback used to return the **ResourceManager** object.|
50
51**Example**
52
53  <!--code_no_check_fa-->
54  ```js
55  import { resourceManager } from '@kit.LocalizationKit';
56  import { BusinessError } from '@kit.BasicServicesKit';
57
58  resourceManager.getResourceManager((error, mgr) => {
59    if (error != null) {
60      console.error("error is " + error);
61      return;
62    }
63    mgr.getStringValue($r('app.string.test').id, (error: BusinessError, value: string) => {
64      if (error != null) {
65        console.error("error is " + error);
66      } else {
67        let str = value;
68      }
69    });
70  });
71  ```
72
73## resourceManager.getResourceManager
74
75getResourceManager(bundleName: string, callback: AsyncCallback&lt;ResourceManager&gt;): void
76
77Obtains the **ResourceManager** object of the specified application. This API uses an asynchronous callback to return the result.
78
79**System capability**: SystemCapability.Global.ResourceManager
80
81**Model restriction**: This API can be used only in the FA model.
82
83**Parameters**
84
85| Name       | Type                                      | Mandatory  | Description                           |
86| ---------- | ---------------------------------------- | ---- | ----------------------------- |
87| bundleName | string                                   | Yes   | Bundle name of the application.                |
88| callback   | [AsyncCallback](#asynccallbackdeprecated)&lt;[ResourceManager](#resourcemanager)&gt; | Yes   | Callback used to return the **ResourceManager** object.|
89
90**Example**
91  <!--code_no_check_fa-->
92  ```js
93  import { resourceManager } from '@kit.LocalizationKit';
94  import { BusinessError } from '@kit.BasicServicesKit';
95
96  resourceManager.getResourceManager("com.example.myapplication", (error, mgr) => {
97    if (error != null) {
98      console.error("error is " + error);
99      return;
100    }
101  });
102  ```
103
104## resourceManager.getResourceManager
105
106getResourceManager(): Promise&lt;ResourceManager&gt;
107
108Obtains the **ResourceManager** object of this application. This API uses a promise to return the result.
109
110**System capability**: SystemCapability.Global.ResourceManager
111
112**Model restriction**: This API can be used only in the FA model.
113
114**Return value**
115
116| Type                                      | Description               |
117| ---------------------------------------- | ----------------- |
118| Promise&lt;[ResourceManager](#resourcemanager)&gt; | Promise used to return the **ResourceManager** object.|
119
120**Example**
121  <!--code_no_check_fa-->
122  ```js
123  import { resourceManager } from '@kit.LocalizationKit';
124  import { BusinessError } from '@kit.BasicServicesKit';
125
126  resourceManager.getResourceManager().then((mgr: resourceManager.ResourceManager) => {
127    mgr.getStringValue($r('app.string.test').id, (error: BusinessError, value: string) => {
128      if (error != null) {
129        console.error("error is " + error);
130      } else {
131        let str = value;
132      }
133    });
134  }).catch((error: BusinessError) => {
135    console.error("error is " + error);
136  });
137  ```
138
139## resourceManager.getResourceManager
140
141getResourceManager(bundleName: string): Promise&lt;ResourceManager&gt;
142
143Obtains the **ResourceManager** object of the specified application. This API uses a promise to return the result.
144
145**System capability**: SystemCapability.Global.ResourceManager
146
147**Model restriction**: This API can be used only in the FA model.
148
149**Parameters**
150
151| Name       | Type    | Mandatory  | Description           |
152| ---------- | ------ | ---- | ------------- |
153| bundleName | string | Yes   | Bundle name of the application.|
154
155**Return value**
156
157| Type                                      | Description                |
158| ---------------------------------------- | ------------------ |
159| Promise&lt;[ResourceManager](#resourcemanager)&gt; | Promise used to return the **ResourceManager** object.|
160
161**Example**
162  <!--code_no_check_fa-->
163  ```js
164  import { resourceManager } from '@kit.LocalizationKit';
165  import { BusinessError } from '@kit.BasicServicesKit';
166
167  resourceManager.getResourceManager("com.example.myapplication").then((mgr: resourceManager.ResourceManager) => {
168  }).catch((error: BusinessError) => {
169    console.error("error is " + error);
170  });
171  ```
172
173## resourceManager.getSysResourceManager<sup>20+</sup>
174
175getSysResourceManager(): ResourceManager
176
177Obtains a **ResourceManager** object.
178
179**Atomic service API**: This API can be used in atomic services since API version 20.
180
181**System capability**: SystemCapability.Global.ResourceManager
182
183**Return value**
184
185| Type                                      | Description                |
186| ---------------------------------------- | ------------------ |
187| [ResourceManager](#resourcemanager) | **ResourceManager** object.|
188
189**Error codes**
190
191For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
192
193| ID| Error Message|
194| -------- | ---------------------------------------- |
195| 9001009  | Failed to access the system resource. which is not mapped to application sandbox, This error code will be thrown. |
196
197**Example**
198  ```js
199import { resourceManager } from '@kit.LocalizationKit';
200import { BusinessError } from '@kit.BasicServicesKit';
201
202  try {
203    let systemResourceManager = resourceManager.getSysResourceManager();
204    systemResourceManager.getStringValue($r('sys.string.ohos_lab_vibrate').id).then((value: string) => {
205      let str = value;
206    }).catch((error: BusinessError) => {
207      console.error(`systemResourceManager getStringValue promise error: ${error}`);
208    });
209  } catch (error) {
210    let code = (error as BusinessError).code;
211    let message = (error as BusinessError).message;
212    console.error(`getSysResourceManager failed, error code: ${code}, message: ${message}.`);
213  }
214  ```
215
216## Direction
217
218Enumerates the screen directions.
219
220**Atomic service API**: This API can be used in atomic services since API version 11.
221
222**System capability**: SystemCapability.Global.ResourceManager
223
224| Name                  | Value | Description  |
225| -------------------- | ---- | ---- |
226| DIRECTION_VERTICAL   | 0    | Portrait  |
227| DIRECTION_HORIZONTAL | 1    | Landscape  |
228
229
230## DeviceType
231
232Enumerates the device types.
233
234**Atomic service API**: This API can be used in atomic services since API version 11.
235
236**System capability**: SystemCapability.Global.ResourceManager
237<!--RP1-->
238| Name                  | Value | Description  |
239| -------------------- | ---- | ---- |
240| DEVICE_TYPE_PHONE    | 0x00 | Phone  |
241| DEVICE_TYPE_TABLET   | 0x01 | Tablet  |
242| DEVICE_TYPE_CAR      | 0x02 | Head unit  |
243| DEVICE_TYPE_TV       | 0x04 | Smart TV |
244| DEVICE_TYPE_WEARABLE | 0x06 | Wearable  |
245| DEVICE_TYPE_2IN1<sup>11+</sup>     | 0x07 | PC/2-in-1 device  |
246<!--RP1End-->
247
248## ScreenDensity
249
250Enumerates the screen density types.
251
252**Atomic service API**: This API can be used in atomic services since API version 11.
253
254**System capability**: SystemCapability.Global.ResourceManager
255
256| Name            | Value | Description        |
257| -------------- | ---- | ---------- |
258| SCREEN_SDPI    | 120  | Small-scale DPI. |
259| SCREEN_MDPI    | 160  | Medium-scale DPI.  |
260| SCREEN_LDPI    | 240  | Large-scale DPI.  |
261| SCREEN_XLDPI   | 320  | Extra-large-scale DPI.  |
262| SCREEN_XXLDPI  | 480  | Extra-extra-large-scale DPI.  |
263| SCREEN_XXXLDPI | 640  | Extra-extra-extra-large-scale DPI.|
264
265
266## ColorMode<sup>12+</sup>
267
268Defines the color mode of the current device.
269
270**Atomic service API**: This API can be used in atomic services since API version 12.
271
272**System capability**: SystemCapability.Global.ResourceManager
273
274| Name | Value  | Description      |
275| ----- | ---- | ---------- |
276| DARK  | 0    | Dark mode.|
277| LIGHT | 1    | Light mode.|
278
279
280## Configuration
281
282Defines the device configuration.
283
284**System capability**: SystemCapability.Global.ResourceManager
285
286| Name                       | Type                           | Read-Only| Optional| Description              |
287| --------------------------- | ------------------------------- | ---- | ---- | ------------------ |
288| direction                   | [Direction](#direction)         | No  | No  | Screen orientation modes.<br>**Atomic service API**: This API can be used in atomic services since API version 11.        |
289| locale                      | string                          | No  | No  | Language locale.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
290| deviceType<sup>12+</sup>    | [DeviceType](#devicetype)       | No  | No  | Device type.<br>**Atomic service API**: This API can be used in atomic services since API version 12.        |
291| screenDensity<sup>12+</sup> | [ScreenDensity](#screendensity) | No  | No  | Screen density<br>**Atomic service API**: This API can be used in atomic services since API version 12.        |
292| colorMode<sup>12+</sup>     | [ColorMode](#colormode12)       | No  | No  | Color mode.<br>**Atomic service API**: This API can be used in atomic services since API version 12.       |
293| mcc<sup>12+</sup>           | number                          | No  | No  | Mobile country code (MCC).<br>**Atomic service API**: This API can be used in atomic services since API version 12.      |
294| mnc<sup>12+</sup>           | number                          | No  | No  | Mobile network code (MNC).<br>**Atomic service API**: This API can be used in atomic services since API version 12.      |
295
296
297
298## DeviceCapability
299
300Defines the device capability.
301
302**Atomic service API**: This API can be used in atomic services since API version 11.
303
304**System capability**: SystemCapability.Global.ResourceManager
305
306| Name           | Type                           | Read-Only  | Optional  | Description      |
307| ------------- | ------------------------------- | ---- | ---- | -------- |
308| screenDensity | [ScreenDensity](#screendensity) | No   | No   | Screen density of the device.|
309| deviceType    | [DeviceType](#devicetype)       | No   | No   | Device type.  |
310
311
312## RawFileDescriptor<sup>9+</sup>
313
314type RawFileDescriptor = _RawFileDescriptor
315
316**Atomic service API**: This API can be used in atomic services since API version 11.
317
318**System capability**: SystemCapability.Global.ResourceManager
319
320| Type   | Description  |
321| ------  | ---- |
322|[_RawFileDescriptor](js-apis-rawFileDescriptor.md#rawfiledescriptor-1)|File descriptor (fd) of the HAP where the raw file is located.|
323
324## Resource<sup>9+</sup>
325
326type Resource = _Resource
327
328**Atomic service API**: This API can be used in atomic services since API version 11.
329
330**System capability**: SystemCapability.Global.ResourceManager
331
332| Type   | Description  |
333| ------  | ---- |
334|[_Resource](js-apis-resource.md#resource-1)|Resource information, including the resource ID, application package name, and module name. Generally, you can use **$r** to obtain the resource information.|
335
336## ResourceManager
337
338Provides APIs for accessing application resources and system resources.
339
340> **NOTE**
341>
342> - The methods involved in **ResourceManager** are applicable only to the TypeScript-based declarative development paradigm.
343>
344> - Resource files are defined in the **resources** directory of the project. You can obtain resource values such as strings, string arrays, and colors based on the specified **resName**, **resId**, or **Resource** object. **resName** indicates the resource name, **resId** indicates the resource ID, which can be obtained through `$r(*resource-address*).id`, for example, `$r('app.string.test').id`.
345>
346> - No matter whether resources are in the same HAP or different HAPs or HSPs, you are advised to use the API with **resName** or **resId** specified. Using the **Resource** object will take a longer time. If the resources are in different HAPs or HSPs, you first need to use [createModuleContext](../apis-ability-kit/js-apis-app-ability-application.md#applicationcreatemodulecontext12) to create the context of the corresponding module and then call the API with **resName** or **resId** specified. For details, see [Resource Access](../../quick-start/resource-categories-and-access.md#resource-access).
347>
348> - For details about the content of the test files used in the sample code, see [Appendix](#appendix).
349
350### getStringSync<sup>9+</sup>
351
352getStringSync(resId: number): string
353
354Obtains a string based on the specified resource ID. This API returns the result synchronously.
355
356**Atomic service API**: This API can be used in atomic services since API version 11.
357
358**System capability**: SystemCapability.Global.ResourceManager
359
360**Parameters**
361
362| Name  | Type    | Mandatory  | Description   |
363| ----- | ------ | ---- | ----- |
364| resId | number | Yes   | Resource ID.|
365
366**Return value**
367
368| Type    | Description         |
369| ------ | ----------- |
370| string | String corresponding to the specified resource ID.|
371
372**Error codes**
373
374For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
375
376| ID| Error Message|
377| -------- | ---------------------------------------- |
378| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
379| 9001001  | Invalid resource ID.                       |
380| 9001002  | No matching resource is found based on the resource ID.         |
381| 9001006  | The resource is referenced cyclically.            |
382
383**Example**
384  ```json
385  // Resource file path: src/main/resources/base/element/string.json
386  {
387    "string": [
388      {
389        "name": "test",
390        "value": "I'm a test string resource."
391      }
392    ]
393  }
394  ```
395  ```ts
396  import { BusinessError } from '@kit.BasicServicesKit';
397
398  try {
399    let testStr = this.context.resourceManager.getStringSync($r('app.string.test').id);
400    console.log(`getStringSync, result: ${testStr}`);
401    // Print the output result: getStringSync, result: I'm a test string resource.
402  } catch (error) {
403    let code = (error as BusinessError).code;
404    let message = (error as BusinessError).message;
405    console.error(`getStringSync failed, error code: ${code}, message: ${message}.`);
406  }
407  ```
408
409### getStringSync<sup>10+</sup>
410
411getStringSync(resId: number, ...args: Array<string | number>): string
412
413Obtains a string based on the specified resource ID and formats the string based on **args**. This API returns the result synchronously.
414
415**Atomic service API**: This API can be used in atomic services since API version 11.
416
417**System capability**: SystemCapability.Global.ResourceManager
418
419**Parameters**
420
421| Name  | Type    | Mandatory  | Description   |
422| ----- | ------ | ---- | ----- |
423| resId | number | Yes   | Resource ID.|
424| ...args | Array<string \| number> | No| Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
425
426**Return value**
427
428| Type    | Description         |
429| ------ | ---------------------------- |
430| string | Formatted string corresponding to the specified resource ID.|
431
432**Error codes**
433
434For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
435
436| ID| Error Message|
437| -------- | ---------------------------------------- |
438| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
439| 9001001  | Invalid resource ID.                               |
440| 9001002  | No matching resource is found based on the resource ID.                 |
441| 9001006  | The resource is referenced cyclically.                    |
442| 9001007  | Failed to format the resource obtained based on the resource ID. |
443
444**Example**
445  ```json
446  // Resource file path: src/main/resources/base/element/string.json
447  {
448    "string": [
449      {
450        "name": "test",
451        "value": "I'm a %1$s, format int: %2$d, format float: %3$f."
452      }
453    ]
454  }
455  ```
456  ```ts
457  import { BusinessError } from '@kit.BasicServicesKit';
458
459  try {
460    let testStr = this.context.resourceManager.getStringSync($r('app.string.test').id, "format string", 10, 98.78);
461    console.log(`getStringSync, result: ${testStr}`);
462    // Print the output result: getStringSync, result: I'm a format string, format int: 10, format float: 98.78.
463  } catch (error) {
464    let code = (error as BusinessError).code;
465    let message = (error as BusinessError).message;
466    console.error(`getStringSync failed, error code: ${code}, message: ${message}.`);
467  }
468  ```
469
470### getStringByNameSync<sup>9+</sup>
471
472getStringByNameSync(resName: string): string
473
474Obtains a string based on the specified resource name. This API returns the result synchronously.
475
476**Atomic service API**: This API can be used in atomic services since API version 11.
477
478**System capability**: SystemCapability.Global.ResourceManager
479
480**Parameters**
481
482| Name    | Type    | Mandatory  | Description  |
483| ------- | ------ | ---- | ---- |
484| resName | string | Yes   | Resource name.|
485
486**Return value**
487
488| Type    | Description        |
489| ------ | ---------- |
490| string | String corresponding to the specified resource name.|
491
492**Error codes**
493
494For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
495
496| ID| Error Message|
497| -------- | ---------------------------------------- |
498| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
499| 9001003  | Invalid resource name.                     |
500| 9001004  | No matching resource is found based on the resource name.       |
501| 9001006  | The resource is referenced cyclically.            |
502
503**Example**
504  ```json
505  // Resource file path: src/main/resources/base/element/string.json
506  {
507    "string": [
508      {
509        "name": "test",
510        "value": "I'm a test string resource."
511      }
512    ]
513  }
514  ```
515  ```ts
516  import { BusinessError } from '@kit.BasicServicesKit';
517
518  try {
519    let testStr = this.context.resourceManager.getStringByNameSync("test");
520    console.log(`getStringByNameSync, result: ${testStr}`);
521    // Print the output result: getStringByNameSync, result: I'm a test string resource.
522  } catch (error) {
523    let code = (error as BusinessError).code;
524    let message = (error as BusinessError).message;
525    console.error(`getStringByNameSync failed, error code: ${code}, message: ${message}.`);
526  }
527  ```
528
529### getStringByNameSync<sup>10+</sup>
530
531getStringByNameSync(resName: string, ...args: Array<string | number>): string
532
533Obtains a string based on the specified resource ame and formats the string based on **args**. This API returns the result synchronously.
534
535**Atomic service API**: This API can be used in atomic services since API version 11.
536
537**System capability**: SystemCapability.Global.ResourceManager
538
539**Parameters**
540
541| Name    | Type    | Mandatory  | Description  |
542| ------- | ------ | ---- | ---- |
543| resName | string | Yes   | Resource name.|
544| ...args | Array<string \| number> | No   | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
545
546**Return value**
547
548| Type    | Description         |
549| ------ | ---------------------------- |
550| string | Formatted string corresponding to the specified resource name.|
551
552**Error codes**
553
554For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
555
556| ID| Error Message|
557| -------- | ---------------------------------------- |
558| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
559| 9001003  | Invalid resource name.                     |
560| 9001004  | No matching resource is found based on the resource name.       |
561| 9001006  | The resource is referenced cyclically.            |
562| 9001008  | Failed to format the resource obtained based on the resource Name. |
563
564**Example**
565  ```json
566  // Resource file path: src/main/resources/base/element/string.json
567  {
568    "string": [
569      {
570        "name": "test",
571        "value": "I'm a %1$s, format int: %2$d, format float: %3$f."
572      }
573    ]
574  }
575  ```
576  ```ts
577  import { BusinessError } from '@kit.BasicServicesKit';
578
579  try {
580    let testStr = this.context.resourceManager.getStringByNameSync("test", "format string", 10, 98.78);
581    console.log(`getStringByNameSync, result: ${testStr}`);
582    // Print the output result: getStringByNameSync, result: I'm a format string, format int: 10, format float: 98.78.
583  } catch (error) {
584    let code = (error as BusinessError).code;
585    let message = (error as BusinessError).message;
586    console.error(`getStringByNameSync failed, error code: ${code}, message: ${message}.`);
587  }
588  ```
589
590### getStringValue<sup>9+</sup>
591
592getStringValue(resId: number, callback: _AsyncCallback&lt;string&gt;): void
593
594Obtains a string based on the specified resource ID. This API uses an asynchronous callback to return the result.
595
596**Atomic service API**: This API can be used in atomic services since API version 11.
597
598**System capability**: SystemCapability.Global.ResourceManager
599
600**Parameters**
601
602| Name     | Type                         | Mandatory  | Description             |
603| -------- | --------------------------- | ---- | --------------- |
604| resId    | number                      | Yes   | Resource ID.          |
605| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the obtained string.|
606
607**Error codes**
608
609For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
610
611| ID| Error Message|
612| -------- | ---------------------------------------- |
613| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
614| 9001001  | If the module resId invalid.             |
615| 9001002  | No matching resource is found based on the resource ID.      |
616| 9001006  | The resource is referenced cyclically.         |
617
618**Example (stage)**
619  ```json
620  // Resource file path: src/main/resources/base/element/string.json
621  {
622    "string": [
623      {
624        "name": "test",
625        "value": "I'm a test string resource."
626      }
627    ]
628  }
629  ```
630  ```ts
631  import { BusinessError } from '@kit.BasicServicesKit';
632
633  this.context.resourceManager.getStringValue($r('app.string.test').id, (error: BusinessError, value: string) => {
634    if (error != null) {
635      console.error(`callback getStringValue failed, error code: ${error.code}, message: ${error.message}.`);
636    } else {
637      console.log(`getStringValue, result: ${value}`);
638      // Print the output result: getStringValue, result: I'm a test string resource.
639    }
640  });
641  ```
642
643### getStringValue<sup>9+</sup>
644
645getStringValue(resId: number): Promise&lt;string&gt;
646
647Obtains a string based on the specified resource ID. This API uses a promise to return the result.
648
649**Atomic service API**: This API can be used in atomic services since API version 11.
650
651**System capability**: SystemCapability.Global.ResourceManager
652
653**Parameters**
654
655| Name  | Type    | Mandatory  | Description   |
656| ----- | ------ | ---- | ----- |
657| resId | number | Yes   | Resource ID.|
658
659**Return value**
660
661| Type                   | Description         |
662| --------------------- | ----------- |
663| Promise&lt;string&gt; | Promise used to return the obtained string.|
664
665**Error codes**
666
667For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
668
669| ID| Error Message|
670| -------- | ---------------------------------------- |
671| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
672| 9001001  | Invalid resource ID.                       |
673| 9001002  | No matching resource is found based on the resource ID.         |
674| 9001006  | The resource is referenced cyclically.            |
675
676**Example**
677  ```json
678  // Resource file path: src/main/resources/base/element/string.json
679  {
680    "string": [
681      {
682        "name": "test",
683        "value": "I'm a test string resource."
684      }
685    ]
686  }
687  ```
688  ```ts
689  import { BusinessError } from '@kit.BasicServicesKit';
690
691  this.context.resourceManager.getStringValue($r('app.string.test').id).then((value: string) => {
692    console.log(`getStringValue, result: ${value}`);
693    // Print the output result: getStringValue, result: I'm a test string resource.
694  }).catch((error: BusinessError) => {
695    console.error(`promise getStringValue failed, error code: ${error.code}, message: ${error.message}.`);
696  });
697  ```
698
699### getStringByName<sup>9+</sup>
700
701getStringByName(resName: string, callback: _AsyncCallback&lt;string&gt;): void
702
703Obtains a string based on the specified resource name. This API uses an asynchronous callback to return the result.
704
705**Atomic service API**: This API can be used in atomic services since API version 11.
706
707**System capability**: SystemCapability.Global.ResourceManager
708
709**Parameters**
710
711| Name     | Type                         | Mandatory  | Description             |
712| -------- | --------------------------- | ---- | --------------- |
713| resName  | string                      | Yes   | Resource name.           |
714| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   |Callback used to return the result, which is the string corresponding to the specified resource ID.|
715
716**Error codes**
717
718For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
719
720| ID| Error Message|
721| -------- | ---------------------------------------- |
722| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
723| 9001003  | Invalid resource name.                     |
724| 9001004  | No matching resource is found based on the resource name.       |
725| 9001006  | The resource is referenced cyclically.            |
726
727**Example**
728  ```json
729  // Resource file path: src/main/resources/base/element/string.json
730  {
731    "string": [
732      {
733        "name": "test",
734        "value": "I'm a test string resource."
735      }
736    ]
737  }
738  ```
739  ```ts
740  import { BusinessError } from '@kit.BasicServicesKit';
741
742  this.context.resourceManager.getStringByName("test", (error: BusinessError, value: string) => {
743    if (error != null) {
744      console.error(`callback getStringByName failed, error code: ${error.code}, message: ${error.message}.`);
745    } else {
746      console.log(`getStringByName, result: ${value}`);
747      // Print the output result: getStringByName, result: I'm a test string resource.
748    }
749  });
750  ```
751
752### getStringByName<sup>9+</sup>
753
754getStringByName(resName: string): Promise&lt;string&gt;
755
756Obtains a string based on the specified resource name. This API uses a promise to return the result.
757
758**Atomic service API**: This API can be used in atomic services since API version 11.
759
760**System capability**: SystemCapability.Global.ResourceManager
761
762**Parameters**
763
764| Name    | Type    | Mandatory  | Description  |
765| ------- | ------ | ---- | ---- |
766| resName | string | Yes   | Resource name.|
767
768**Return value**
769
770| Type                   | Description        |
771| --------------------- | ---------- |
772| Promise&lt;string&gt; | Promise used to return the obtained string.|
773
774**Error codes**
775
776For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
777
778| ID| Error Message|
779| -------- | ---------------------------------------- |
780| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
781| 9001003  | Invalid resource name.                     |
782| 9001004  | No matching resource is found based on the resource name.       |
783| 9001006  | The resource is referenced cyclically.            |
784
785**Example**
786  ```json
787  // Resource file path: src/main/resources/base/element/string.json
788  {
789    "string": [
790      {
791        "name": "test",
792        "value": "I'm a test string resource."
793      }
794    ]
795  }
796  ```
797  ```ts
798  import { BusinessError } from '@kit.BasicServicesKit';
799
800  this.context.resourceManager.getStringByName("test").then((value: string) => {
801    console.log(`getStringByName, result: ${value}`);
802    // Print the output result: getStringByName, result: I'm a test string resource.
803  }).catch((error: BusinessError) => {
804    console.error(`promise getStringByName failed, error code: ${error.code}, message: ${error.message}.`);
805  });
806  ```
807
808### getStringArrayValueSync<sup>10+</sup>
809
810getStringArrayValueSync(resId: number): Array&lt;string&gt;
811
812Obtains a string array based on the specified resource ID. This API returns the result synchronously.
813
814**Atomic service API**: This API can be used in atomic services since API version 11.
815
816**System capability**: SystemCapability.Global.ResourceManager
817
818**Parameters**
819
820| Name  | Type    | Mandatory  | Description   |
821| ----- | ------ | ---- | ----- |
822| resId | number | Yes   | Resource ID.|
823
824**Return value**
825
826| Type                   | Description         |
827| --------------------- | ----------- |
828| Array&lt;string&gt; | String array corresponding to the specified resource ID.|
829
830**Error codes**
831
832For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
833
834| ID| Error Message|
835| -------- | ---------------------------------------- |
836| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
837| 9001001  | Invalid resource ID.                       |
838| 9001002  | No matching resource is found based on the resource ID.         |
839| 9001006  | The resource is referenced cyclically.            |
840
841**Example**
842  ```json
843  // Resource file path: src/main/resources/base/element/strarray.json
844  {
845    "strarray": [
846      {
847        "name": "test",
848        "value": [
849          {
850            "value": "I'm one of the array's values."
851          }
852        ]
853      }
854    ]
855  }
856  ```
857  ```ts
858  import { BusinessError } from '@kit.BasicServicesKit';
859
860  try {
861    let strArray: Array<string> = this.context.resourceManager.getStringArrayValueSync($r('app.strarray.test').id);
862    console.log(`getStringArrayValueSync, result: ${strArray[0]}`);
863    // Print the output result: getStringArrayValueSync, result: I'm one of the array's values.
864  } catch (error) {
865    let code = (error as BusinessError).code;
866    let message = (error as BusinessError).message;
867    console.error(`getStringArrayValueSync failed, error code: ${code}, message: ${message}.`);
868  }
869  ```
870
871### getStringArrayByNameSync<sup>10+</sup>
872
873getStringArrayByNameSync(resName: string): Array&lt;string&gt;
874
875Obtains a string array based on the specified resource name. This API returns the result synchronously.
876
877**Atomic service API**: This API can be used in atomic services since API version 11.
878
879**System capability**: SystemCapability.Global.ResourceManager
880
881**Parameters**
882
883| Name  | Type    | Mandatory  | Description   |
884| ----- | ------ | ---- | ----- |
885| resName | string | Yes   | Resource name.|
886
887**Return value**
888
889| Type                   | Description         |
890| --------------------- | ----------- |
891| Array&lt;string&gt; | String array corresponding to the specified resource name.|
892
893**Error codes**
894
895For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
896
897| ID| Error Message|
898| -------- | ---------------------------------------- |
899| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
900| 9001003  | Invalid resource name.                       |
901| 9001004  | No matching resource is found based on the resource name.         |
902| 9001006  | The resource is referenced cyclically.            |
903
904**Example**
905  ```json
906  // Resource file path: src/main/resources/base/element/strarray.json
907  {
908    "strarray": [
909      {
910        "name": "test",
911        "value": [
912          {
913            "value": "I'm one of the array's values."
914          }
915        ]
916      }
917    ]
918  }
919  ```
920  ```ts
921  import { BusinessError } from '@kit.BasicServicesKit';
922
923  try {
924    let strArray: Array<string> = this.context.resourceManager.getStringArrayByNameSync("test");
925    console.log(`getStringArrayByNameSync, result: ${strArray[0]}`);
926    // Print the output result: getStringArrayByNameSync, result: I'm one of the array's values.
927  } catch (error) {
928    let code = (error as BusinessError).code;
929    let message = (error as BusinessError).message;
930    console.error(`getStringArrayByNameSync failed, error code: ${code}, message: ${message}.`);
931  }
932  ```
933
934### getStringArrayValue<sup>9+</sup>
935
936getStringArrayValue(resId: number, callback: _AsyncCallback&lt;Array&lt;string&gt;&gt;): void
937
938Obtains a string array based on the specified resource ID. This API uses an asynchronous callback to return the result.
939
940**Atomic service API**: This API can be used in atomic services since API version 11.
941
942**System capability**: SystemCapability.Global.ResourceManager
943
944**Parameters**
945
946| Name     | Type                                      | Mandatory  | Description               |
947| -------- | ---------------------------------------- | ---- | ----------------- |
948| resId    | number                                   | Yes   | Resource ID.            |
949| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Array&lt;string&gt;&gt; | Yes   | Callback used to return the obtained string array.|
950
951**Error codes**
952
953For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
954
955| ID| Error Message|
956| -------- | ---------------------------------------- |
957| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
958| 9001001  | Invalid resource ID.                       |
959| 9001002  | No matching resource is found based on the resource ID.         |
960| 9001006  | The resource is referenced cyclically.            |
961
962**Example**
963  ```json
964  // Resource file path: src/main/resources/base/element/strarray.json
965  {
966    "strarray": [
967      {
968        "name": "test",
969        "value": [
970          {
971            "value": "I'm one of the array's values."
972          }
973        ]
974      }
975    ]
976  }
977  ```
978  ```ts
979  import { BusinessError } from '@kit.BasicServicesKit';
980
981  this.context.resourceManager.getStringArrayValue($r('app.strarray.test').id,
982    (error: BusinessError, value: Array<string>) => {
983      if (error != null) {
984        console.error(`callback getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`);
985      } else {
986        console.log(`getStringArrayValue, result: ${value[0]}`);
987        // Print the output result: getStringArrayValue, result: I'm one of the array's values.
988      }
989    });
990  ```
991
992### getStringArrayValue<sup>9+</sup>
993
994getStringArrayValue(resId: number): Promise&lt;Array&lt;string&gt;&gt;
995
996Obtains a string array based on the specified resource ID. This API uses a promise to return the result.
997
998**Atomic service API**: This API can be used in atomic services since API version 11.
999
1000**System capability**: SystemCapability.Global.ResourceManager
1001
1002**Parameters**
1003
1004| Name  | Type    | Mandatory  | Description   |
1005| ----- | ------ | ---- | ----- |
1006| resId | number | Yes   | Resource ID.|
1007
1008**Return value**
1009
1010| Type                                | Description           |
1011| ---------------------------------- | ------------- |
1012| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the obtained string array.|
1013
1014**Error codes**
1015
1016For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1017
1018| ID| Error Message|
1019| -------- | ---------------------------------------- |
1020| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
1021| 9001001  | Invalid resource ID.                       |
1022| 9001002  | No matching resource is found based on the resource ID.         |
1023| 9001006  | The resource is referenced cyclically.            |
1024
1025**Example**
1026  ```json
1027  // Resource file path: src/main/resources/base/element/strarray.json
1028  {
1029    "strarray": [
1030      {
1031        "name": "test",
1032        "value": [
1033          {
1034            "value": "I'm one of the array's values."
1035          }
1036        ]
1037      }
1038    ]
1039  }
1040  ```
1041  ```ts
1042  import { BusinessError } from '@kit.BasicServicesKit';
1043
1044  this.context.resourceManager.getStringArrayValue($r('app.strarray.test').id)
1045    .then((value: Array<string>) => {
1046      console.log(`getStringArrayValue, result: ${value[0]}`);
1047      // Print the output result: getStringArrayValue, result: I'm one of the array's values.
1048    })
1049    .catch((error: BusinessError) => {
1050      console.error(`promise getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`);
1051    });
1052  ```
1053
1054### getStringArrayByName<sup>9+</sup>
1055
1056getStringArrayByName(resName: string, callback: _AsyncCallback&lt;Array&lt;string&gt;&gt;): void
1057
1058Obtains a string array based on the specified resource name. This API uses an asynchronous callback to return the result.
1059
1060**Atomic service API**: This API can be used in atomic services since API version 11.
1061
1062**System capability**: SystemCapability.Global.ResourceManager
1063
1064**Parameters**
1065
1066| Name     | Type                                      | Mandatory  | Description               |
1067| -------- | ---------------------------------------- | ---- | ----------------- |
1068| resName  | string                                   | Yes   | Resource name.             |
1069| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Array&lt;string&gt;&gt; | Yes   | Callback used to return the obtained string array.|
1070
1071**Error codes**
1072
1073For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1074
1075| ID| Error Message|
1076| -------- | ---------------------------------------- |
1077| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
1078| 9001003  | Invalid resource name.                     |
1079| 9001004  | No matching resource is found based on the resource name.       |
1080| 9001006  | The resource is referenced cyclically.            |
1081
1082**Example**
1083  ```json
1084  // Resource file path: src/main/resources/base/element/strarray.json
1085  {
1086    "strarray": [
1087      {
1088        "name": "test",
1089        "value": [
1090          {
1091            "value": "I'm one of the array's values."
1092          }
1093        ]
1094      }
1095    ]
1096  }
1097  ```
1098  ```ts
1099  import { BusinessError } from '@kit.BasicServicesKit';
1100
1101  this.context.resourceManager.getStringArrayByName("test", (error: BusinessError, value: Array<string>) => {
1102    if (error != null) {
1103      console.error(`callback getStringArrayByName failed, error code: ${error.code}, message: ${error.message}.`);
1104    } else {
1105      let strArray = value;
1106      console.log(`getStringArrayByName, result: ${value[0]}`);
1107      // Print the output result: getStringArrayByName, result: I'm one of the array's values.
1108    }
1109  });
1110  ```
1111
1112### getStringArrayByName<sup>9+</sup>
1113
1114getStringArrayByName(resName: string): Promise&lt;Array&lt;string&gt;&gt;
1115
1116Obtains a string array based on the specified resource name. This API uses a promise to return the result.
1117
1118**Atomic service API**: This API can be used in atomic services since API version 11.
1119
1120**System capability**: SystemCapability.Global.ResourceManager
1121
1122**Parameters**
1123
1124| Name    | Type    | Mandatory  | Description  |
1125| ------- | ------ | ---- | ---- |
1126| resName | string | Yes   | Resource name.|
1127
1128**Return value**
1129
1130| Type                                | Description          |
1131| ---------------------------------- | ------------ |
1132| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the obtained string array.|
1133
1134**Error codes**
1135
1136For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1137
1138| ID| Error Message|
1139| -------- | ---------------------------------------- |
1140| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
1141| 9001003  | Invalid resource name.                     |
1142| 9001004  | No matching resource is found based on the resource name.       |
1143| 9001006  | The resource is referenced cyclically.            |
1144
1145**Example**
1146  ```json
1147  // Resource file path: src/main/resources/base/element/strarray.json
1148  {
1149    "strarray": [
1150      {
1151        "name": "test",
1152        "value": [
1153          {
1154            "value": "I'm one of the array's values."
1155          }
1156        ]
1157      }
1158    ]
1159  }
1160  ```
1161  ```ts
1162  import { BusinessError } from '@kit.BasicServicesKit';
1163
1164  this.context.resourceManager.getStringArrayByName("test")
1165    .then((value: Array<string>) => {
1166      console.log(`getStringArrayByName, result: ${value[0]}`);
1167      // Print the output result: getStringArrayByName, result: I'm one of the array's values.
1168    })
1169    .catch((error: BusinessError) => {
1170      console.error(`promise getStringArrayByName failed, error code: ${error.code}, message: ${error.message}.`);
1171    });
1172  ```
1173
1174### getIntPluralStringValueSync<sup>18+</sup>
1175
1176getIntPluralStringValueSync(resId: number, num: number, ...args: Array<string | number>): string
1177
1178Obtains a [singular/plural](../../internationalization/l10n-singular-plural.md) string based on the specified resource ID and formats the string based on the **args** parameter. This API returns the result synchronously.
1179
1180> **NOTE**
1181>
1182> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
1183
1184**Atomic service API**: This API can be used in atomic services since API version 18.
1185
1186**System capability**: SystemCapability.Global.ResourceManager
1187
1188**Parameters**
1189
1190| Name | Type                   | Mandatory| Description                                                        |
1191| ------- | ----------------------- | ---- | ------------------------------------------------------------ |
1192| resId   | number                  | Yes  | Resource ID.                                                  |
1193| num     | number                  | Yes  | Integer number used to obtain the corresponding string representation based on the current language's [plural rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
1194| ...args | Array<string \| number> | No  | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
1195
1196**Return value**
1197
1198| Type  | Description                  |
1199| ------ | ---------------------- |
1200| string | Formatted string corresponding to the specified resource ID.|
1201
1202**Error codes**
1203
1204For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
1205
1206| ID| Error Message                                                    |
1207| -------- | ------------------------------------------------------------ |
1208| 9001001  | Invalid resource ID.                                         |
1209| 9001002  | No matching resource is found based on the resource ID.      |
1210| 9001006  | The resource is referenced cyclically.                       |
1211| 9001007  | Failed to format the resource obtained based on the resource ID. |
1212
1213**Example**
1214  ```json
1215  // Resource file path: src/main/resources/base/element/plural.json
1216  {
1217    "plural": [
1218      {
1219        "name": "format_test",
1220        "value": [
1221          {
1222            "quantity": "one",
1223            "value": "There is %d apple in the %s, the total amount is %f kg."
1224          },
1225          {
1226            "quantity": "other",
1227            "value": "There are %d apples in the %s, the total amount is %f kg."
1228          }
1229        ]
1230      }
1231    ]
1232  }
1233  ```
1234  ```ts
1235  import { BusinessError } from '@kit.BasicServicesKit';
1236
1237  try {
1238    // If num is 1, the single/plural type is one in the English environment.
1239    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
1240    let pluralStr = this.context.resourceManager.getIntPluralStringValueSync($r('app.plural.format_test').id, 1, 1, "basket", 0.3);
1241    console.log(`getIntPluralStringValueSync, result: ${pluralStr}`);
1242    // Print the output result: getIntPluralStringValueSync, result: There is 1 apple in the basket, the total amount is 0.3 kg.
1243  } catch (error) {
1244    let code = (error as BusinessError).code;
1245    let message = (error as BusinessError).message;
1246    console.error(`getIntPluralStringValueSync failed, error code: ${code}, message: ${message}.`);
1247  }
1248  ```
1249
1250### getIntPluralStringByNameSync<sup>18+</sup>
1251
1252getIntPluralStringByNameSync(resName: string, num: number, ...args: Array<string | number>): string
1253
1254Obtains a [singular/plural](../../internationalization/l10n-singular-plural.md) string based on the specified resource name and formats the string based on the **args** parameter. This API returns the result synchronously.
1255
1256> **NOTE**
1257>
1258> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
1259
1260**Atomic service API**: This API can be used in atomic services since API version 18.
1261
1262**System capability**: SystemCapability.Global.ResourceManager
1263
1264**Parameters**
1265
1266| Name | Type                   | Mandatory| Description                                                        |
1267| ------- | ----------------------- | ---- | ------------------------------------------------------------ |
1268| resName | string                  | Yes  | Resource name.                                                  |
1269| num     | number                  | Yes  | Integer number used to obtain the corresponding string representation based on the current language's [plural rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
1270| ...args | Array<string \| number> | No  | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
1271
1272**Return value**
1273
1274| Type  | Description                                |
1275| ------ | ------------------------------------ |
1276| string | Formatted string corresponding to the specified resource name.|
1277
1278**Error codes**
1279
1280For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
1281
1282| ID| Error Message                                                    |
1283| -------- | ------------------------------------------------------------ |
1284| 9001003  | Invalid resource name.                                       |
1285| 9001004  | No matching resource is found based on the resource name.    |
1286| 9001006  | The resource is referenced cyclically.                       |
1287| 9001008  | Failed to format the resource obtained based on the resource name. |
1288
1289**Example**
1290  ```json
1291  // Resource file path: src/main/resources/base/element/plural.json
1292  {
1293    "plural": [
1294      {
1295        "name": "format_test",
1296        "value": [
1297          {
1298            "quantity": "one",
1299            "value": "There is %d apple in the %s, the total amount is %f kg."
1300          },
1301          {
1302            "quantity": "other",
1303            "value": "There are %d apples in the %s, the total amount is %f kg."
1304          }
1305        ]
1306      }
1307    ]
1308  }
1309  ```
1310  ```ts
1311  import { BusinessError } from '@kit.BasicServicesKit';
1312
1313  try {
1314    // If num is 1, the single/plural type is one in the English environment.
1315    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
1316    let pluralStr = this.context.resourceManager.getIntPluralStringByNameSync("format_test", 1, 1, "basket", 0.3);
1317    console.log(`getIntPluralStringByNameSync, result: ${pluralStr}`);
1318    // Print the output result: getIntPluralStringByNameSync, result: There is 1 apple in the basket, the total amount is 0.3 kg.
1319  } catch (error) {
1320    let code = (error as BusinessError).code;
1321    let message = (error as BusinessError).message;
1322    console.error(`getIntPluralStringByNameSync failed, error code: ${code}, message: ${message}.`);
1323  }
1324  ```
1325
1326### getDoublePluralStringValueSync<sup>18+</sup>
1327
1328getDoublePluralStringValueSync(resId: number, num: number, ...args: Array<string | number>): string
1329
1330Obtains a [singular/plural](../../internationalization/l10n-singular-plural.md) string based on the specified resource ID and formats the string based on the **args** parameter. This API returns the result synchronously.
1331
1332> **NOTE**
1333>
1334> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
1335
1336**Atomic service API**: This API can be used in atomic services since API version 18.
1337
1338**System capability**: SystemCapability.Global.ResourceManager
1339
1340**Parameters**
1341
1342| Name | Type                   | Mandatory| Description                                                        |
1343| ------- | ----------------------- | ---- | ------------------------------------------------------------ |
1344| resId   | number                  | Yes  | Resource ID.                                                  |
1345| num     | number                  | Yes  | Quantity value (a floating point number), used to obtain the corresponding string representation based on the current language's [plural rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
1346| ...args | Array<string \| number> | No  | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
1347
1348**Return value**
1349
1350| Type  | Description                            |
1351| ------ | -------------------------------- |
1352| string | Formatted string corresponding to the specified resource ID.|
1353
1354**Error codes**
1355
1356For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
1357
1358| ID| Error Message                                                    |
1359| -------- | ------------------------------------------------------------ |
1360| 9001001  | Invalid resource ID.                                         |
1361| 9001002  | No matching resource is found based on the resource ID.      |
1362| 9001006  | The resource is referenced cyclically.                       |
1363| 9001007  | Failed to format the resource obtained based on the resource ID. |
1364
1365**Example**
1366  ```json
1367  // Resource file path: src/main/resources/base/element/plural.json
1368  {
1369    "plural": [
1370      {
1371        "name": "format_test",
1372        "value": [
1373          {
1374            "quantity": "one",
1375            "value": "There is %d apple in the %s, the total amount is %f kg."
1376          },
1377          {
1378            "quantity": "other",
1379            "value": "There are %d apples in the %s, the total amount is %f kg."
1380          }
1381        ]
1382      }
1383    ]
1384  }
1385  ```
1386  ```ts
1387  import { BusinessError } from '@kit.BasicServicesKit';
1388
1389  try {
1390    // If num is 2.1, the single/plural type is other in the English environment.
1391    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is other is obtained.
1392    let pluralStr = this.context.resourceManager.getDoublePluralStringValueSync($r('app.plural.format_test').id, 2.1, 2, "basket", 0.6);
1393    console.log(`getDoublePluralStringValueSync, result: ${pluralStr}`);
1394    // Print the output result: getDoublePluralStringValueSync, result: There are 2 apples in the basket, the total amount is 0.6 kg.
1395  } catch (error) {
1396    let code = (error as BusinessError).code;
1397    let message = (error as BusinessError).message;
1398    console.error(`getDoublePluralStringValueSync failed, error code: ${code}, message: ${message}.`);
1399  }
1400  ```
1401
1402### getDoublePluralStringByNameSync<sup>18+</sup>
1403
1404getDoublePluralStringByNameSync(resName: string, num: number, ...args: Array<string | number>): string
1405
1406Obtains a [singular/plural](../../internationalization/l10n-singular-plural.md) string based on the specified resource name and formats the string based on the **args** parameter. This API returns the result synchronously.
1407
1408> **NOTE**
1409>
1410> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
1411
1412**Atomic service API**: This API can be used in atomic services since API version 18.
1413
1414**System capability**: SystemCapability.Global.ResourceManager
1415
1416**Parameters**
1417
1418| Name | Type                   | Mandatory| Description                                                        |
1419| ------- | ----------------------- | ---- | ------------------------------------------------------------ |
1420| resName | string                  | Yes  | Resource name.                                                  |
1421| num     | number                  | Yes  | Quantity value (a floating point number), used to obtain the corresponding string representation based on the current language's [plural rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
1422| ...args | Array<string \| number> | No  | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
1423
1424**Return value**
1425
1426| Type  | Description                            |
1427| ------ | -------------------------------- |
1428| string | Formatted string corresponding to the specified resource name.|
1429
1430**Error codes**
1431
1432For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
1433
1434| ID| Error Message                                                    |
1435| -------- | ------------------------------------------------------------ |
1436| 9001003  | Invalid resource name.                                       |
1437| 9001004  | No matching resource is found based on the resource name.    |
1438| 9001006  | The resource is referenced cyclically.                       |
1439| 9001008  | Failed to format the resource obtained based on the resource name. |
1440
1441**Example**
1442  ```json
1443  // Resource file path: src/main/resources/base/element/plural.json
1444  {
1445    "plural": [
1446      {
1447        "name": "format_test",
1448        "value": [
1449          {
1450            "quantity": "one",
1451            "value": "There is %d apple in the %s, the total amount is %f kg."
1452          },
1453          {
1454            "quantity": "other",
1455            "value": "There are %d apples in the %s, the total amount is %f kg."
1456          }
1457        ]
1458      }
1459    ]
1460  }
1461  ```
1462  ```ts
1463  import { BusinessError } from '@kit.BasicServicesKit';
1464
1465  try {
1466    // If num is 2.1, the single/plural type is other in the English environment.
1467    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is other is obtained.
1468    let pluralStr = this.context.resourceManager.getDoublePluralStringByNameSync("format_test", 2.1, 2, "basket", 0.6);
1469    console.log(`getDoublePluralStringByNameSync, result: ${pluralStr}`);
1470    // Print the output result: getIntPluralStringValueSync, result: There are 2 apples in the basket, the total amount is 0.6 kg.
1471  } catch (error) {
1472    let code = (error as BusinessError).code;
1473    let message = (error as BusinessError).message;
1474    console.error(`getDoublePluralStringByNameSync failed, error code: ${code}, message: ${message}.`);
1475  }
1476  ```
1477
1478### getMediaContentSync<sup>10+</sup>
1479
1480getMediaContentSync(resId: number, density?: number): Uint8Array
1481
1482Obtains the media file content for the default or specified screen density based on the specified resource ID. This API returns the result synchronously.
1483
1484**Atomic service API**: This API can be used in atomic services since API version 11.
1485
1486**System capability**: SystemCapability.Global.ResourceManager
1487
1488**Parameters**
1489
1490| Name  | Type    | Mandatory  | Description   |
1491| ----- | ------ | ---- | ----- |
1492| resId | number | Yes   | Resource ID.|
1493| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
1494
1495**Return value**
1496
1497| Type                   | Description         |
1498| -------- | ----------- |
1499| Uint8Array   | Content of the media file corresponding to the specified resource ID.|
1500
1501**Error codes**
1502
1503For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1504
1505| ID| Error Message|
1506| -------- | ---------------------------------------- |
1507| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
1508| 9001001  | Invalid resource ID.                       |
1509| 9001002  | No matching resource is found based on the resource ID.         |
1510
1511**Example**
1512  ```ts
1513  import { BusinessError } from '@kit.BasicServicesKit';
1514
1515  try {
1516    this.context.resourceManager.getMediaContentSync($r('app.media.test').id); // Default screen density
1517  } catch (error) {
1518    let code = (error as BusinessError).code;
1519    let message = (error as BusinessError).message;
1520    console.error(`getMediaContentSync failed, error code: ${code}, message: ${message}.`);
1521  }
1522
1523  try {
1524    this.context.resourceManager.getMediaContentSync($r('app.media.test').id, 120); // Specified screen density
1525  } catch (error) {
1526    let code = (error as BusinessError).code;
1527    let message = (error as BusinessError).message;
1528    console.error(`getMediaContentSync failed, error code: ${code}, message: ${message}.`);
1529  }
1530  ```
1531
1532### getMediaByNameSync<sup>10+</sup>
1533
1534getMediaByNameSync(resName: string, density?: number): Uint8Array
1535
1536Obtains the media file content for the default or specified screen density based on the specified resource name. This API returns the result synchronously.
1537
1538**Atomic service API**: This API can be used in atomic services since API version 11.
1539
1540**System capability**: SystemCapability.Global.ResourceManager
1541
1542**Parameters**
1543
1544| Name  | Type    | Mandatory  | Description   |
1545| ----- | ------ | ---- | ----- |
1546| resName | string | Yes   | Resource name.|
1547| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
1548
1549**Return value**
1550
1551| Type                   | Description         |
1552| --------------------- | ----------- |
1553| Uint8Array | Promise used to return the result, which is the content of the media file corresponding to the specified resource name.|
1554
1555**Error codes**
1556
1557For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1558
1559| ID| Error Message|
1560| -------- | ---------------------------------------- |
1561| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
1562| 9001003  | Invalid resource name.                       |
1563| 9001004  | No matching resource is found based on the resource name.         |
1564
1565**Example**
1566  ```ts
1567  import { BusinessError } from '@kit.BasicServicesKit';
1568
1569  try {
1570    this.context.resourceManager.getMediaByNameSync("test"); // Default screen density
1571  } catch (error) {
1572    let code = (error as BusinessError).code;
1573    let message = (error as BusinessError).message;
1574    console.error(`getMediaByNameSync failed, error code: ${code}, message: ${message}.`);
1575  }
1576
1577  try {
1578    this.context.resourceManager.getMediaByNameSync("test", 120); // Specified screen density
1579  } catch (error) {
1580    let code = (error as BusinessError).code;
1581    let message = (error as BusinessError).message;
1582    console.error(`getMediaByNameSync failed, error code: ${code}, message: ${message}.`);
1583  }
1584  ```
1585
1586### getMediaContent<sup>9+</sup>
1587
1588getMediaContent(resId: number, callback: _AsyncCallback&lt;Uint8Array&gt;): void
1589
1590Obtains media file content based on the specified resource ID. This API uses an asynchronous callback to return the result.
1591
1592**Atomic service API**: This API can be used in atomic services since API version 11.
1593
1594**System capability**: SystemCapability.Global.ResourceManager
1595
1596**Parameters**
1597
1598| Name     | Type                             | Mandatory  | Description                |
1599| -------- | ------------------------------- | ---- | ------------------ |
1600| resId    | number                          | Yes   | Resource ID.             |
1601| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
1602
1603**Error codes**
1604
1605For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1606
1607| ID| Error Message|
1608| -------- | ---------------------------------------- |
1609| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.              |
1610| 9001001  | Invalid resource ID.                       |
1611| 9001002  | No matching resource is found based on the resource ID.         |
1612
1613**Example**
1614  ```ts
1615  import { BusinessError } from '@kit.BasicServicesKit';
1616
1617  try {
1618    this.context.resourceManager.getMediaContent($r('app.media.test').id, (error: BusinessError, value: Uint8Array) => {
1619      if (error != null) {
1620        console.error("error is " + error);
1621      } else {
1622        let media = value;
1623      }
1624    });
1625  } catch (error) {
1626    let code = (error as BusinessError).code;
1627    let message = (error as BusinessError).message;
1628    console.error(`callback getMediaContent failed, error code: ${code}, message: ${message}.`);
1629  }
1630  ```
1631
1632### getMediaContent<sup>10+</sup>
1633
1634getMediaContent(resId: number, density: number, callback: _AsyncCallback&lt;Uint8Array&gt;): void
1635
1636Obtains the media file content for the specified screen density based on the specified resource ID. This API uses an asynchronous callback to return the result.
1637
1638**Atomic service API**: This API can be used in atomic services since API version 11.
1639
1640**System capability**: SystemCapability.Global.ResourceManager
1641
1642**Parameters**
1643
1644| Name     | Type                             | Mandatory  | Description                |
1645| -------- | ------------------------------- | ---- | ------------------ |
1646| resId    | number                          | Yes   | Resource ID.             |
1647| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
1648| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
1649
1650**Error codes**
1651
1652For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1653
1654| ID| Error Message|
1655| -------- | ---------------------------------------- |
1656| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
1657| 9001001  | Invalid resource ID.                       |
1658| 9001002  | No matching resource is found based on the resource ID.         |
1659
1660**Example**
1661  ```ts
1662  import { BusinessError } from '@kit.BasicServicesKit';
1663
1664  try {
1665    this.context.resourceManager.getMediaContent($r('app.media.test').id, 120, (error: BusinessError, value: Uint8Array) => {
1666      if (error != null) {
1667        console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
1668      } else {
1669        let media = value;
1670      }
1671    });
1672  } catch (error) {
1673    let code = (error as BusinessError).code;
1674    let message = (error as BusinessError).message;
1675    console.error(`callback getMediaContent failed, error code: ${code}, message: ${message}.`);
1676  }
1677  ```
1678
1679### getMediaContent<sup>9+</sup>
1680
1681getMediaContent(resId: number): Promise&lt;Uint8Array&gt;
1682
1683Obtains media file content based on the specified resource ID. This API uses a promise to return the result.
1684
1685**Atomic service API**: This API can be used in atomic services since API version 11.
1686
1687**System capability**: SystemCapability.Global.ResourceManager
1688
1689**Parameters**
1690
1691| Name  | Type    | Mandatory  | Description   |
1692| ----- | ------ | ---- | ----- |
1693| resId | number | Yes   | Resource ID.|
1694
1695**Return value**
1696
1697| Type                       | Description            |
1698| ------------------------- | -------------- |
1699| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
1700
1701**Error codes**
1702
1703For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1704
1705| ID| Error Message|
1706| -------- | ---------------------------------------- |
1707| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
1708| 9001001  | Invalid resource ID.                       |
1709| 9001002  | No matching resource is found based on the resource ID.         |
1710
1711**Example**
1712  ```ts
1713  import { BusinessError } from '@kit.BasicServicesKit';
1714
1715  try {
1716    this.context.resourceManager.getMediaContent($r('app.media.test').id).then((value: Uint8Array) => {
1717      let media = value;
1718    }).catch((error: BusinessError) => {
1719      console.error("getMediaContent promise error is " + error);
1720    });
1721  } catch (error) {
1722    let code = (error as BusinessError).code;
1723    let message = (error as BusinessError).message;
1724    console.error(`promise getMediaContent failed, error code: ${code}, message: ${message}.`);
1725  }
1726  ```
1727
1728### getMediaContent<sup>10+</sup>
1729
1730getMediaContent(resId: number, density: number): Promise&lt;Uint8Array&gt;
1731
1732Obtains the media file content for the specified screen density based on the specified resource ID. This API uses a promise to return the result.
1733
1734**Atomic service API**: This API can be used in atomic services since API version 11.
1735
1736**System capability**: SystemCapability.Global.ResourceManager
1737
1738**Parameters**
1739
1740| Name  | Type    | Mandatory  | Description   |
1741| ----- | ------ | ---- | ----- |
1742| resId | number | Yes   | Resource ID.|
1743| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
1744
1745**Return value**
1746
1747| Type                       | Description            |
1748| ------------------------- | -------------- |
1749| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
1750
1751**Error codes**
1752
1753For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1754
1755| ID| Error Message|
1756| -------- | ---------------------------------------- |
1757| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
1758| 9001001  | Invalid resource ID.                       |
1759| 9001002  | No matching resource is found based on the resource ID.         |
1760
1761**Example**
1762  ```ts
1763  import { BusinessError } from '@kit.BasicServicesKit';
1764
1765  try {
1766    this.context.resourceManager.getMediaContent($r('app.media.test').id, 120).then((value: Uint8Array) => {
1767      let media = value;
1768    }).catch((error: BusinessError) => {
1769      console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
1770    });
1771  } catch (error) {
1772    let code = (error as BusinessError).code;
1773    let message = (error as BusinessError).message;
1774    console.error(`promise getMediaContent failed, error code: ${code}, message: ${message}.`);
1775  }
1776  ```
1777
1778### getMediaByName<sup>9+</sup>
1779
1780getMediaByName(resName: string, callback: _AsyncCallback&lt;Uint8Array&gt;): void
1781
1782Obtains media file content based on the specified resource name. This API uses an asynchronous callback to return the result.
1783
1784**Atomic service API**: This API can be used in atomic services since API version 11.
1785
1786**System capability**: SystemCapability.Global.ResourceManager
1787
1788**Parameters**
1789
1790| Name     | Type                             | Mandatory  | Description                |
1791| -------- | ------------------------------- | ---- | ------------------ |
1792| resName  | string                          | Yes   | Resource name.              |
1793| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
1794
1795**Error codes**
1796
1797For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1798
1799| ID| Error Message|
1800| -------- | ---------------------------------------- |
1801| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
1802| 9001003  | Invalid resource name.                     |
1803| 9001004  | No matching resource is found based on the resource name.       |
1804
1805**Example**
1806  ```ts
1807  import { BusinessError } from '@kit.BasicServicesKit';
1808
1809  try {
1810    this.context.resourceManager.getMediaByName("test", (error: BusinessError, value: Uint8Array) => {
1811      if (error != null) {
1812        console.error("error is " + error);
1813      } else {
1814        let media = value;
1815      }
1816    });
1817  } catch (error) {
1818    let code = (error as BusinessError).code;
1819    let message = (error as BusinessError).message;
1820    console.error(`callback getMediaByName failed, error code: ${code}, message: ${message}.`);
1821  }
1822  ```
1823
1824### getMediaByName<sup>10+</sup>
1825
1826getMediaByName(resName: string, density: number, callback: _AsyncCallback&lt;Uint8Array&gt;): void
1827
1828Obtains the media file content for the specified screen density based on the specified resource name. This API uses an asynchronous callback to return the result.
1829
1830**Atomic service API**: This API can be used in atomic services since API version 11.
1831
1832**System capability**: SystemCapability.Global.ResourceManager
1833
1834**Parameters**
1835
1836| Name     | Type                             | Mandatory  | Description                |
1837| -------- | ------------------------------- | ---- | ------------------ |
1838| resName  | string                          | Yes   | Resource name.              |
1839| [density](#screendensity)  | number        | Yes   | Screen density. The value **0** indicates the default screen density.   |
1840| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
1841
1842**Error codes**
1843
1844For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1845
1846| ID| Error Message|
1847| -------- | ---------------------------------------- |
1848| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
1849| 9001003  | Invalid resource name.                     |
1850| 9001004  | No matching resource is found based on the resource name.       |
1851
1852**Example**
1853  ```ts
1854  import { BusinessError } from '@kit.BasicServicesKit';
1855
1856  try {
1857    this.context.resourceManager.getMediaByName("test", 120, (error: BusinessError, value: Uint8Array) => {
1858      if (error != null) {
1859        console.error(`callback getMediaByName failed, error code: ${error.code}, message: ${error.message}.`);
1860      } else {
1861        let media = value;
1862      }
1863    });
1864  } catch (error) {
1865    let code = (error as BusinessError).code;
1866    let message = (error as BusinessError).message;
1867    console.error(`callback getMediaByName failed, error code: ${code}, message: ${message}.`);
1868  }
1869  ```
1870
1871### getMediaByName<sup>9+</sup>
1872
1873getMediaByName(resName: string): Promise&lt;Uint8Array&gt;
1874
1875Obtains media file content based on the specified resource name. This API uses a promise to return the result.
1876
1877**Atomic service API**: This API can be used in atomic services since API version 11.
1878
1879**System capability**: SystemCapability.Global.ResourceManager
1880
1881**Parameters**
1882
1883| Name    | Type    | Mandatory  | Description  |
1884| ------- | ------ | ---- | ---- |
1885| resName | string | Yes   | Resource name.|
1886
1887**Return value**
1888
1889| Type                       | Description           |
1890| ------------------------- | ------------- |
1891| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
1892
1893**Error codes**
1894
1895For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1896
1897| ID| Error Message|
1898| -------- | ---------------------------------------- |
1899| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
1900| 9001003  | Invalid resource name.                     |
1901| 9001004  | No matching resource is found based on the resource name.       |
1902
1903**Example**
1904  ```ts
1905  import { BusinessError } from '@kit.BasicServicesKit';
1906
1907  try {
1908    this.context.resourceManager.getMediaByName("test").then((value: Uint8Array) => {
1909      let media = value;
1910    }).catch((error: BusinessError) => {
1911      console.error("getMediaByName promise error is " + error);
1912    });
1913  } catch (error) {
1914    let code = (error as BusinessError).code;
1915    let message = (error as BusinessError).message;
1916    console.error(`promise getMediaByName failed, error code: ${code}, message: ${message}.`);
1917  }
1918  ```
1919
1920### getMediaByName<sup>10+</sup>
1921
1922getMediaByName(resName: string, density: number): Promise&lt;Uint8Array&gt;
1923
1924Obtains the media file content for the specified screen density based on the specified resource name. This API uses a promise to return the result.
1925
1926**Atomic service API**: This API can be used in atomic services since API version 11.
1927
1928**System capability**: SystemCapability.Global.ResourceManager
1929
1930**Parameters**
1931
1932| Name    | Type    | Mandatory  | Description  |
1933| ------- | ------ | ---- | ---- |
1934| resName | string | Yes   | Resource name.|
1935| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
1936
1937**Return value**
1938
1939| Type                       | Description           |
1940| ------------------------- | ------------- |
1941| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
1942
1943**Error codes**
1944
1945For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1946
1947| ID| Error Message|
1948| -------- | ---------------------------------------- |
1949| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
1950| 9001003  | Invalid resource name.                     |
1951| 9001004  | No matching resource is found based on the resource name.       |
1952
1953**Example**
1954  ```ts
1955  import { BusinessError } from '@kit.BasicServicesKit';
1956
1957  try {
1958    this.context.resourceManager.getMediaByName("test", 120).then((value: Uint8Array) => {
1959      let media = value;
1960    }).catch((error: BusinessError) => {
1961      console.error(`promise getMediaByName failed, error code: ${error.code}, message: ${error.message}.`);
1962    });
1963  } catch (error) {
1964    let code = (error as BusinessError).code;
1965    let message = (error as BusinessError).message;
1966    console.error(`promise getMediaByName failed, error code: ${code}, message: ${message}.`);
1967  }
1968  ```
1969
1970### getMediaContentBase64Sync<sup>10+</sup>
1971
1972getMediaContentBase64Sync(resId: number, density?: number): string
1973
1974Obtains an image's Base64 code for the default or specified screen density based on the specified resource ID. This API returns the result synchronously.
1975
1976**Atomic service API**: This API can be used in atomic services since API version 11.
1977
1978**System capability**: SystemCapability.Global.ResourceManager
1979
1980**Parameters**
1981
1982| Name  | Type    | Mandatory  | Description   |
1983| ----- | ------ | ---- | ----- |
1984| resId | number | Yes   | Resource ID.|
1985| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
1986
1987**Return value**
1988
1989| Type                   | Description         |
1990| -------- | ----------- |
1991| string   | Base64 code of the image corresponding to the specified resource ID.|
1992
1993**Error codes**
1994
1995For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
1996
1997| ID| Error Message|
1998| -------- | ---------------------------------------- |
1999| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2000| 9001001  | Invalid resource ID.                       |
2001| 9001002  | No matching resource is found based on the resource ID.         |
2002
2003**Example**
2004  ```ts
2005  import { BusinessError } from '@kit.BasicServicesKit';
2006
2007  try {
2008    this.context.resourceManager.getMediaContentBase64Sync($r('app.media.test').id); // Default screen density
2009  } catch (error) {
2010    let code = (error as BusinessError).code;
2011    let message = (error as BusinessError).message;
2012    console.error(`getMediaContentBase64Sync failed, error code: ${code}, message: ${message}.`);
2013  }
2014
2015  try {
2016    this.context.resourceManager.getMediaContentBase64Sync($r('app.media.test').id, 120); // Specified screen density
2017  } catch (error) {
2018    let code = (error as BusinessError).code;
2019    let message = (error as BusinessError).message;
2020    console.error(`getMediaContentBase64Sync failed, error code: ${code}, message: ${message}.`);
2021  }
2022  ```
2023
2024### getMediaBase64ByNameSync<sup>10+</sup>
2025
2026getMediaBase64ByNameSync(resName: string, density?: number): string
2027
2028Obtains an image's Base64 code for the default or specified screen density based on the specified resource name. This API returns the result synchronously.
2029
2030**Atomic service API**: This API can be used in atomic services since API version 11.
2031
2032**System capability**: SystemCapability.Global.ResourceManager
2033
2034**Parameters**
2035
2036| Name  | Type    | Mandatory  | Description   |
2037| ----- | ------ | ---- | ----- |
2038| resName | string | Yes   | Resource name.|
2039| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
2040
2041**Return value**
2042
2043| Type                   | Description         |
2044| --------------------- | ----------- |
2045| string | Base64 code of the image corresponding to the specified resource name.|
2046
2047**Error codes**
2048
2049For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2050
2051| ID| Error Message|
2052| -------- | ---------------------------------------- |
2053| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2054| 9001003  | Invalid resource name.                       |
2055| 9001004  | No matching resource is found based on the resource name.         |
2056
2057**Example**
2058  ```ts
2059  import { BusinessError } from '@kit.BasicServicesKit';
2060
2061  try {
2062    this.context.resourceManager.getMediaBase64ByNameSync("test"); // Default screen density
2063  } catch (error) {
2064    let code = (error as BusinessError).code;
2065    let message = (error as BusinessError).message;
2066    console.error(`getMediaBase64ByNameSync failed, error code: ${code}, message: ${message}.`);
2067  }
2068
2069  try {
2070    this.context.resourceManager.getMediaBase64ByNameSync("test", 120); // Specified screen density
2071  } catch (error) {
2072    let code = (error as BusinessError).code;
2073    let message = (error as BusinessError).message;
2074    console.error(`getMediaBase64ByNameSync failed, error code: ${code}, message: ${message}.`);
2075  }
2076  ```
2077
2078### getMediaContentBase64<sup>9+</sup>
2079
2080getMediaContentBase64(resId: number, callback: _AsyncCallback&lt;string&gt;): void
2081
2082Obtains an image's Base64 code based on the specified resource ID. This API uses an asynchronous callback to return the result.
2083
2084**Atomic service API**: This API can be used in atomic services since API version 11.
2085
2086**System capability**: SystemCapability.Global.ResourceManager
2087
2088**Parameters**
2089
2090| Name     | Type                         | Mandatory  | Description                      |
2091| -------- | --------------------------- | ---- | ------------------------ |
2092| resId    | number                      | Yes   | Resource ID.                   |
2093| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
2094
2095**Error codes**
2096
2097For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2098
2099| ID| Error Message|
2100| -------- | ---------------------------------------- |
2101| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2102| 9001001  | Invalid resource ID.                       |
2103| 9001002  | No matching resource is found based on the resource ID.         |
2104
2105**Example**
2106  ```ts
2107  import { BusinessError } from '@kit.BasicServicesKit';
2108
2109  try {
2110    this.context.resourceManager.getMediaContentBase64($r('app.media.test').id, (error: BusinessError, value: string) => {
2111      if (error != null) {
2112        console.error("error is " + error);
2113      } else {
2114        let media = value;
2115      }
2116    });
2117  } catch (error) {
2118    let code = (error as BusinessError).code;
2119    let message = (error as BusinessError).message;
2120    console.error(`callback getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
2121  }
2122  ```
2123
2124### getMediaContentBase64<sup>10+</sup>
2125
2126getMediaContentBase64(resId: number, density: number, callback: _AsyncCallback&lt;string&gt;): void
2127
2128Obtains an image's Base64 code for the specified screen density based on the specified resource ID. This API uses an asynchronous callback to return the result.
2129
2130**Atomic service API**: This API can be used in atomic services since API version 11.
2131
2132**System capability**: SystemCapability.Global.ResourceManager
2133
2134**Parameters**
2135
2136| Name     | Type                         | Mandatory  | Description                      |
2137| -------- | --------------------------- | ---- | ------------------------ |
2138| resId    | number                      | Yes   | Resource ID.                   |
2139| [density](#screendensity)  | number        | Yes   | Screen density. The value **0** indicates the default screen density.   |
2140| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
2141
2142**Error codes**
2143
2144For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2145
2146| ID| Error Message|
2147| -------- | ---------------------------------------- |
2148| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2149| 9001001  | Invalid resource ID.                       |
2150| 9001002  | No matching resource is found based on the resource ID.         |
2151
2152**Example**
2153  ```ts
2154  import { BusinessError } from '@kit.BasicServicesKit';
2155
2156  try {
2157    this.context.resourceManager.getMediaContentBase64($r('app.media.test').id, 120, (error: BusinessError, value: string) => {
2158      if (error != null) {
2159        console.error(`callback getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
2160      } else {
2161        let media = value;
2162      }
2163    });
2164  } catch (error) {
2165    let code = (error as BusinessError).code;
2166    let message = (error as BusinessError).message;
2167    console.error(`callback getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
2168  }
2169  ```
2170
2171### getMediaContentBase64<sup>9+</sup>
2172
2173getMediaContentBase64(resId: number): Promise&lt;string&gt;
2174
2175Obtains an image's Base64 code based on the specified resource ID. This API uses a promise to return the result.
2176
2177**Atomic service API**: This API can be used in atomic services since API version 11.
2178
2179**System capability**: SystemCapability.Global.ResourceManager
2180
2181**Parameters**
2182
2183| Name  | Type    | Mandatory  | Description   |
2184| ----- | ------ | ---- | ----- |
2185| resId | number | Yes   | Resource ID.|
2186
2187**Return value**
2188
2189| Type                   | Description                  |
2190| --------------------- | -------------------- |
2191| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
2192
2193**Error codes**
2194
2195For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2196
2197| ID| Error Message|
2198| -------- | ---------------------------------------- |
2199| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2200| 9001001  | Invalid resource ID.                       |
2201| 9001002  | No matching resource is found based on the resource ID.         |
2202
2203**Example**
2204  ```ts
2205  import { BusinessError } from '@kit.BasicServicesKit';
2206
2207  try {
2208    this.context.resourceManager.getMediaContentBase64($r('app.media.test').id).then((value: string) => {
2209      let media = value;
2210    }).catch((error: BusinessError) => {
2211      console.error("getMediaContentBase64 promise error is " + error);
2212    });
2213  } catch (error) {
2214    let code = (error as BusinessError).code;
2215    let message = (error as BusinessError).message;
2216    console.error(`promise getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
2217  }
2218  ```
2219
2220### getMediaContentBase64<sup>10+</sup>
2221
2222getMediaContentBase64(resId: number, density: number): Promise&lt;string&gt;
2223
2224Obtains an image's Base64 code for the specified screen density based on the specified resource ID. This API uses a promise to return the result.
2225
2226**Atomic service API**: This API can be used in atomic services since API version 11.
2227
2228**System capability**: SystemCapability.Global.ResourceManager
2229
2230**Parameters**
2231
2232| Name  | Type    | Mandatory  | Description   |
2233| ----- | ------ | ---- | ----- |
2234| resId | number | Yes   | Resource ID.|
2235| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
2236
2237**Return value**
2238
2239| Type                   | Description                  |
2240| --------------------- | -------------------- |
2241| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
2242
2243**Error codes**
2244
2245For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2246
2247| ID| Error Message|
2248| -------- | ---------------------------------------- |
2249| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2250| 9001001  | Invalid resource ID.                       |
2251| 9001002  | No matching resource is found based on the resource ID.         |
2252
2253**Example**
2254  ```ts
2255  import { BusinessError } from '@kit.BasicServicesKit';
2256
2257  try {
2258    this.context.resourceManager.getMediaContentBase64($r('app.media.test').id, 120).then((value: string) => {
2259      let media = value;
2260    }).catch((error: BusinessError) => {
2261      console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
2262    });
2263  } catch (error) {
2264    let code = (error as BusinessError).code;
2265    let message = (error as BusinessError).message;
2266    console.error(`promise getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
2267  }
2268  ```
2269
2270### getMediaBase64ByName<sup>9+</sup>
2271
2272getMediaBase64ByName(resName: string, callback: _AsyncCallback&lt;string&gt;): void
2273
2274Obtains an image's Base64 code based on the specified resource name. This API uses an asynchronous callback to return the result.
2275
2276**Atomic service API**: This API can be used in atomic services since API version 11.
2277
2278**System capability**: SystemCapability.Global.ResourceManager
2279
2280**Parameters**
2281
2282| Name     | Type                         | Mandatory  | Description                      |
2283| -------- | --------------------------- | ---- | ------------------------ |
2284| resName  | string                      | Yes   | Resource name.                    |
2285| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
2286
2287**Error codes**
2288
2289For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2290
2291| ID| Error Message|
2292| -------- | ---------------------------------------- |
2293| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2294| 9001003  | Invalid resource name.                     |
2295| 9001004  | No matching resource is found based on the resource name.       |
2296
2297**Example**
2298  ```ts
2299  import { BusinessError } from '@kit.BasicServicesKit';
2300
2301  try {
2302    this.context.resourceManager.getMediaBase64ByName("test", (error: BusinessError, value: string) => {
2303      if (error != null) {
2304        console.error("error is " + error);
2305      } else {
2306        let media = value;
2307      }
2308    });
2309  } catch (error) {
2310    let code = (error as BusinessError).code;
2311    let message = (error as BusinessError).message;
2312    console.error(`callback getMediaBase64ByName failed, error code: ${code}, message: ${message}.`);
2313  }
2314  ```
2315
2316### getMediaBase64ByName<sup>10+</sup>
2317
2318getMediaBase64ByName(resName: string, density: number, callback: _AsyncCallback&lt;string&gt;): void
2319
2320Obtains an image's Base64 code for the specified screen density based on the specified resource name. This API uses an asynchronous callback to return the result.
2321
2322> **NOTE**
2323>
2324> You are advised to use [getMediaBase64ByName](#getmediacontentbase6410) or [getMediaContentBase64](#getmediacontentbase6410). For details, see [ResourceManager](#resourcemanager).
2325
2326**Atomic service API**: This API can be used in atomic services since API version 11.
2327
2328**System capability**: SystemCapability.Global.ResourceManager
2329
2330**Parameters**
2331
2332| Name     | Type                         | Mandatory  | Description                      |
2333| -------- | --------------------------- | ---- | ------------------------ |
2334| resName  | string                      | Yes   | Resource name.                    |
2335| [density](#screendensity)  | number        | Yes   | Screen density. The value **0** indicates the default screen density.   |
2336| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
2337
2338**Error codes**
2339
2340For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2341
2342| ID| Error Message|
2343| -------- | ---------------------------------------- |
2344| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2345| 9001003  | Invalid resource name.                     |
2346| 9001004  | No matching resource is found based on the resource name.       |
2347
2348**Example**
2349  ```ts
2350  import { BusinessError } from '@kit.BasicServicesKit';
2351
2352  try {
2353    this.context.resourceManager.getMediaBase64ByName("test", 120, (error: BusinessError, value: string) => {
2354      if (error != null) {
2355        console.error(`callback getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`);
2356      } else {
2357        let media = value;
2358      }
2359    });
2360  } catch (error) {
2361    let code = (error as BusinessError).code;
2362    let message = (error as BusinessError).message;
2363    console.error(`callback getMediaBase64ByName failed, error code: ${code}, message: ${message}.`);
2364  }
2365  ```
2366
2367### getMediaBase64ByName<sup>9+</sup>
2368
2369getMediaBase64ByName(resName: string): Promise&lt;string&gt;
2370
2371Obtains an image's Base64 code based on the specified resource name. This API uses a promise to return the result.
2372
2373**Atomic service API**: This API can be used in atomic services since API version 11.
2374
2375**System capability**: SystemCapability.Global.ResourceManager
2376
2377**Parameters**
2378
2379| Name    | Type    | Mandatory  | Description  |
2380| ------- | ------ | ---- | ---- |
2381| resName | string | Yes   | Resource name.|
2382
2383**Return value**
2384
2385| Type                   | Description                 |
2386| --------------------- | ------------------- |
2387| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
2388
2389**Error codes**
2390
2391For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2392
2393| ID| Error Message|
2394| -------- | ---------------------------------------- |
2395| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2396| 9001003  | Invalid resource name.                     |
2397| 9001004  | No matching resource is found based on the resource name.       |
2398
2399**Example**
2400  ```ts
2401  import { BusinessError } from '@kit.BasicServicesKit';
2402
2403  try {
2404    this.context.resourceManager.getMediaBase64ByName("test").then((value: string) => {
2405      let media = value;
2406    }).catch((error: BusinessError) => {
2407      console.error("getMediaBase64ByName promise error is " + error);
2408    });
2409  } catch (error) {
2410    let code = (error as BusinessError).code;
2411    let message = (error as BusinessError).message;
2412    console.error(`promise getMediaBase64ByName failed, error code: ${code}, message: ${message}.`);
2413  }
2414  ```
2415
2416### getMediaBase64ByName<sup>10+</sup>
2417
2418getMediaBase64ByName(resName: string, density: number): Promise&lt;string&gt;
2419
2420Obtains an image's Base64 code for the specified screen density based on the specified resource name. This API uses a promise to return the result.
2421
2422**Atomic service API**: This API can be used in atomic services since API version 11.
2423
2424**System capability**: SystemCapability.Global.ResourceManager
2425
2426**Parameters**
2427
2428| Name    | Type    | Mandatory  | Description  |
2429| ------- | ------ | ---- | ---- |
2430| resName | string | Yes   | Resource name.|
2431| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
2432
2433**Return value**
2434
2435| Type                   | Description                 |
2436| --------------------- | ------------------- |
2437| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
2438
2439**Error codes**
2440
2441For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2442
2443| ID| Error Message|
2444| -------- | ---------------------------------------- |
2445| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2446| 9001003  | Invalid resource name.                     |
2447| 9001004  | No matching resource is found based on the resource name.       |
2448
2449**Example**
2450  ```ts
2451  import { BusinessError } from '@kit.BasicServicesKit';
2452
2453  try {
2454    this.context.resourceManager.getMediaBase64ByName("test", 120).then((value: string) => {
2455      let media = value;
2456    }).catch((error: BusinessError) => {
2457      console.error(`promise getMediaBase64ByName failed, error code: ${error.code}, message: ${error.message}.`);
2458    });
2459  } catch (error) {
2460    let code = (error as BusinessError).code;
2461    let message = (error as BusinessError).message;
2462    console.error(`promise getMediaBase64ByName failed, error code: ${code}, message: ${message}.`);
2463  }
2464  ```
2465
2466### getDrawableDescriptor<sup>10+</sup>
2467
2468getDrawableDescriptor(resId: number, density?: number, type?: number): DrawableDescriptor
2469
2470Obtains a **DrawableDescriptor** object for icon display based on the specified resource ID. This API returns the result synchronously.
2471
2472**Atomic service API**: This API can be used in atomic services since API version 11.
2473
2474**System capability**: SystemCapability.Global.ResourceManager
2475
2476**Parameters**
2477
2478| Name  | Type    | Mandatory  | Description   |
2479| ----- | ------ | ---- | ----- |
2480| resId | number | Yes   | Resource ID.|
2481| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
2482| type<sup>11+</sup> | number | No   | - **1**: Layered icon resource of the application in the theme resource package.<br> - **0** or default value: Icon resource of the application.|
2483
2484**Return value**
2485
2486| Type    | Description        |
2487| ------ | ---------- |
2488| [DrawableDescriptor](../apis-arkui/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | **DrawableDescriptor** object corresponding to the specified resource ID.|
2489
2490**Error codes**
2491
2492For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2493
2494| ID| Error Message|
2495| -------- | ---------------------------------------- |
2496| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2497| 9001001  | Invalid resource ID.                       |
2498| 9001002  | No matching resource is found based on the resource ID.         |
2499
2500**Example**
2501  ```ts
2502  import { BusinessError } from '@kit.BasicServicesKit';
2503  import { DrawableDescriptor } from '@kit.ArkUI';
2504
2505  try {
2506    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id);
2507  } catch (error) {
2508    let code = (error as BusinessError).code;
2509    let message = (error as BusinessError).message;
2510    console.error(`getDrawableDescriptor failed, error code: ${code}, message: ${message}.`);
2511  }
2512  try {
2513    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id, 120);
2514  } catch (error) {
2515    let code = (error as BusinessError).code;
2516    let message = (error as BusinessError).message;
2517    console.error(`getDrawableDescriptor failed, error code: ${code}, message: ${message}.`);
2518  }
2519  try {
2520    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptor($r('app.media.icon').id, 0, 1);
2521  } catch (error) {
2522    let code = (error as BusinessError).code;
2523    let message = (error as BusinessError).message;
2524    console.error(`getDrawableDescriptor failed, error code: ${code}, message: ${message}.`);
2525  }
2526  ```
2527
2528### getDrawableDescriptorByName<sup>10+</sup>
2529
2530getDrawableDescriptorByName(resName: string, density?: number, type?: number): DrawableDescriptor
2531
2532Obtains a **DrawableDescriptor** object for icon display based on the specified resource name. This API returns the result synchronously.
2533
2534**Atomic service API**: This API can be used in atomic services since API version 11.
2535
2536**System capability**: SystemCapability.Global.ResourceManager
2537
2538**Parameters**
2539
2540| Name    | Type    | Mandatory  | Description  |
2541| ------- | ------ | ---- | ---- |
2542| resName | string | Yes   | Resource name.|
2543| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
2544| type<sup>11+</sup> | number | No   | - **1**: Layered icon resource of the application in the theme resource package.<br> - **0** or default value: Icon resource of the application.|
2545
2546**Return value**
2547
2548| Type    | Description       |
2549| ------ | --------- |
2550| [DrawableDescriptor](../apis-arkui/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | **DrawableDescriptor** object.|
2551
2552**Error codes**
2553
2554For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2555
2556| ID| Error Message|
2557| -------- | ---------------------------------------- |
2558| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
2559| 9001003  | Invalid resource name.                     |
2560| 9001004  | No matching resource is found based on the resource name.       |
2561
2562**Example**
2563  ```ts
2564  import { BusinessError } from '@kit.BasicServicesKit';
2565  import { DrawableDescriptor } from '@kit.ArkUI';
2566
2567  try {
2568    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptorByName('icon');
2569  } catch (error) {
2570    let code = (error as BusinessError).code;
2571    let message = (error as BusinessError).message;
2572    console.error(`getDrawableDescriptorByName failed, error code: ${code}, message: ${message}.`);
2573  }
2574  try {
2575    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptorByName('icon', 120);
2576  } catch (error) {
2577    let code = (error as BusinessError).code;
2578    let message = (error as BusinessError).message;
2579    console.error(`getDrawableDescriptorByName failed, error code: ${code}, message: ${message}.`);
2580  }
2581  try {
2582    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptorByName('icon', 0, 1);
2583  } catch (error) {
2584    let code = (error as BusinessError).code;
2585    let message = (error as BusinessError).message;
2586    console.error(`getDrawableDescriptorByName failed, error code: ${code}, message: ${message}.`);
2587  }
2588  ```
2589
2590### getBoolean<sup>9+</sup>
2591
2592getBoolean(resId: number): boolean
2593
2594Obtains a Boolean value based on the specified resource ID. This API returns the result synchronously.
2595
2596**Atomic service API**: This API can be used in atomic services since API version 11.
2597
2598**System capability**: SystemCapability.Global.ResourceManager
2599
2600**Parameters**
2601
2602| Name  | Type    | Mandatory  | Description   |
2603| ----- | ------ | ---- | ----- |
2604| resId | number | Yes   | Resource ID.|
2605
2606**Return value**
2607
2608| Type     | Description          |
2609| ------- | ------------ |
2610| boolean | Boolean value.|
2611
2612**Error codes**
2613
2614For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2615
2616| ID| Error Message|
2617| -------- | ---------------------------------------- |
2618| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2619| 9001001  | Invalid resource ID.                       |
2620| 9001002  | No matching resource is found based on the resource ID.         |
2621| 9001006  | The resource is referenced cyclically.            |
2622
2623**Example**
2624  ```json
2625  // Resource file path: src/main/resources/base/element/boolean.json
2626  {
2627    "boolean": [
2628      {
2629        "name": "boolean_test",
2630        "value": true
2631      }
2632    ]
2633  }
2634  ```
2635  ```ts
2636  import { BusinessError } from '@kit.BasicServicesKit';
2637
2638  try {
2639    let boolTest = this.context.resourceManager.getBoolean($r('app.boolean.boolean_test').id);
2640    console.log(`getBoolean, result: ${boolTest}`);
2641    // Print the output result: getBoolean, result: true
2642  } catch (error) {
2643    let code = (error as BusinessError).code;
2644    let message = (error as BusinessError).message;
2645    console.error(`getBoolean failed, error code: ${code}, message: ${message}.`);
2646  }
2647  ```
2648
2649### getBooleanByName<sup>9+</sup>
2650
2651getBooleanByName(resName: string): boolean
2652
2653Obtains a Boolean value based on the specified resource name. This API returns the result synchronously.
2654
2655**Atomic service API**: This API can be used in atomic services since API version 11.
2656
2657**System capability**: SystemCapability.Global.ResourceManager
2658
2659**Parameters**
2660
2661| Name    | Type    | Mandatory  | Description  |
2662| ------- | ------ | ---- | ---- |
2663| resName | string | Yes   | Resource name.|
2664
2665**Return value**
2666
2667| Type     | Description         |
2668| ------- | ----------- |
2669| boolean | Boolean value.|
2670
2671**Error codes**
2672
2673For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2674
2675| ID| Error Message|
2676| -------- | ---------------------------------------- |
2677| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2678| 9001003  | Invalid resource name.                     |
2679| 9001004  | No matching resource is found based on the resource name.       |
2680| 9001006  | The resource is referenced cyclically.            |
2681
2682**Example**
2683  ```json
2684  // Resource file path: src/main/resources/base/element/boolean.json
2685  {
2686    "boolean": [
2687      {
2688        "name": "boolean_test",
2689        "value": true
2690      }
2691    ]
2692  }
2693  ```
2694  ```ts
2695  import { BusinessError } from '@kit.BasicServicesKit';
2696
2697  try {
2698    let boolTest = this.context.resourceManager.getBooleanByName("boolean_test");
2699    console.log(`getBooleanByName, result: ${boolTest}`);
2700    // Print the output result: getBooleanByName, result: true
2701  } catch (error) {
2702    let code = (error as BusinessError).code;
2703    let message = (error as BusinessError).message;
2704    console.error(`getBooleanByName failed, error code: ${code}, message: ${message}.`);
2705  }
2706  ```
2707
2708### getNumber<sup>9+</sup>
2709
2710getNumber(resId: number): number
2711
2712Obtains an integer or float number based on the specified resource ID. This API returns the result synchronously.
2713
2714**Atomic service API**: This API can be used in atomic services since API version 11.
2715
2716**System capability**: SystemCapability.Global.ResourceManager
2717
2718**Parameters**
2719
2720| Name  | Type    | Mandatory  | Description   |
2721| ----- | ------ | ---- | ----- |
2722| resId | number | Yes   | Resource ID.|
2723
2724**Return value**
2725
2726| Type    | Description        |
2727| ------ | ---------- |
2728| number | Integer or float value corresponding to the specified resource ID.<br>An integer indicates the original value, and a float number without a unit indicates the original value and a float number with the unit of vp or fp indicates the px value. For details, see the sample code.|
2729
2730**Error codes**
2731
2732For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2733
2734| ID| Error Message|
2735| -------- | ---------------------------------------- |
2736| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2737| 9001001  | Invalid resource ID.                       |
2738| 9001002  | No matching resource is found based on the resource ID.         |
2739| 9001006  | The resource is referenced cyclically.            |
2740
2741**Example**
2742  ```json
2743  // Resource file path: src/main/resources/base/element/integer.json
2744  {
2745    "integer": [
2746      {
2747        "name": "integer_test",
2748        "value": 100
2749      }
2750    ]
2751  }
2752  ```
2753
2754  ```json
2755  // Resource file path: src/main/resources/base/element/float.json
2756  {
2757    "float": [
2758      {
2759        "name": "float_test",
2760        "value": "30.6vp"
2761      }
2762    ]
2763  }
2764  ```
2765  ```ts
2766  import { BusinessError } from '@kit.BasicServicesKit';
2767  import { display } from '@kit.ArkUI';
2768
2769  try {
2770    // An integer refers to the original value.
2771    let intValue = this.context.resourceManager.getNumber($r('app.integer.integer_test').id);
2772    console.log(`getNumber, int value: ${intValue}`);
2773    // Print the output result: getNumber, int value: 100
2774  } catch (error) {
2775    let code = (error as BusinessError).code;
2776    let message = (error as BusinessError).message;
2777    console.error(`getNumber failed, error code: ${code}, message: ${message}.`);
2778  }
2779
2780  try {
2781    // A float number without a unit indicates the original value, and a float number with the unit of vp or fp indicates the px value (float number with the unit of vp or fp = original value x densityPixels).
2782    let floatValue = this.context.resourceManager.getNumber($r('app.float.float_test').id);
2783    console.log(`getNumber, densityPixels: ${display.getDefaultDisplaySync().densityPixels}, float value: ${floatValue}`);
2784    // Print the output result: getNumber, densityPixels: 3.25, float value: 99.45000457763672
2785  } catch (error) {
2786    let code = (error as BusinessError).code;
2787    let message = (error as BusinessError).message;
2788    console.error(`getNumber failed, error code: ${code}, message: ${message}.`);
2789  }
2790  ```
2791
2792
2793### getNumberByName<sup>9+</sup>
2794
2795getNumberByName(resName: string): number
2796
2797Obtains an integer or float number based on the specified resource name. This API returns the result synchronously.
2798
2799**Atomic service API**: This API can be used in atomic services since API version 11.
2800
2801**System capability**: SystemCapability.Global.ResourceManager
2802
2803**Parameters**
2804
2805| Name    | Type    | Mandatory  | Description  |
2806| ------- | ------ | ---- | ---- |
2807| resName | string | Yes   | Resource name.|
2808
2809**Return value**
2810
2811| Type    | Description       |
2812| ------ | --------- |
2813| number | Integer or float value corresponding to the specified resource name.<br>An integer indicates the original value, and a float number without a unit indicates the original value and a float number with the unit of vp or fp indicates the px value.|
2814
2815**Error codes**
2816
2817For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2818
2819| ID| Error Message|
2820| -------- | ---------------------------------------- |
2821| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2822| 9001003  | Invalid resource name.                     |
2823| 9001004  | No matching resource is found based on the resource name.       |
2824| 9001006  | The resource is referenced cyclically.            |
2825
2826**Example**
2827  ```json
2828  // Resource file path: src/main/resources/base/element/integer.json
2829  {
2830    "integer": [
2831      {
2832        "name": "integer_test",
2833        "value": 100
2834      }
2835    ]
2836  }
2837  ```
2838
2839  ```json
2840  // Resource file path: src/main/resources/base/element/float.json
2841  {
2842    "float": [
2843      {
2844        "name": "float_test",
2845        "value": "30.6vp"
2846      }
2847    ]
2848  }
2849  ```
2850  ```ts
2851  import { BusinessError } from '@kit.BasicServicesKit';
2852  import { display } from '@kit.ArkUI';
2853
2854  try {
2855    // An integer refers to the original value.
2856    let intValue = this.context.resourceManager.getNumberByName("integer_test");
2857    console.log(`getNumberByName, int value: ${intValue}`);
2858    // Print the output result: getNumberByName, int value: 100
2859  } catch (error) {
2860    let code = (error as BusinessError).code;
2861    let message = (error as BusinessError).message;
2862    console.error(`getNumberByName failed, error code: ${code}, message: ${message}.`);
2863  }
2864
2865  try {
2866    // A float number without a unit indicates the original value, and a float number with the unit of vp or fp indicates the px value (float number with the unit of vp or fp = original value x densityPixels).
2867    let floatValue = this.context.resourceManager.getNumberByName("float_test");
2868    console.log(`getNumberByName, densityPixels: ${display.getDefaultDisplaySync().densityPixels}, float value: ${floatValue}`);
2869    // Print the output result: getNumberByName, densityPixels: 3.25, float value: 99.45000457763672
2870  } catch (error) {
2871    let code = (error as BusinessError).code;
2872    let message = (error as BusinessError).message;
2873    console.error(`getNumberByName failed, error code: ${code}, message: ${message}.`);
2874  }
2875  ```
2876
2877### getColorSync<sup>10+</sup>
2878
2879getColorSync(resId: number) : number
2880
2881Obtains a color value based on the specified resource ID. This API returns the result synchronously.
2882
2883**Atomic service API**: This API can be used in atomic services since API version 11.
2884
2885**System capability**: SystemCapability.Global.ResourceManager
2886
2887**Parameters**
2888
2889| Name  | Type    | Mandatory  | Description   |
2890| ----- | ------ | ---- | ----- |
2891| resId | number | Yes   | Resource ID.|
2892
2893**Return value**
2894
2895| Type    | Description         |
2896| ------ | ----------- |
2897| number | Color value (decimal) corresponding to the specified resource ID.|
2898
2899**Error codes**
2900
2901For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2902
2903| ID| Error Message|
2904| -------- | ---------------------------------------- |
2905| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2906| 9001001  | Invalid resource ID.                       |
2907| 9001002  | No matching resource is found based on the resource ID.         |
2908| 9001006  | The resource is referenced cyclically.            |
2909
2910**Example**
2911  ```json
2912  // Resource file path: src/main/resources/base/element/color.json
2913  {
2914    "color": [
2915      {
2916        "name": "test",
2917        "value": "#FFFFFF"
2918      }
2919    ]
2920  }
2921  ```
2922  ```ts
2923  import { BusinessError } from '@kit.BasicServicesKit';
2924
2925  try {
2926    let colorValue = this.context.resourceManager.getColorSync($r('app.color.test').id);
2927    console.log(`getColorSync, result: ${colorValue}`);
2928    // Print the output result: getColorSync, result: 4294967295
2929  } catch (error) {
2930    let code = (error as BusinessError).code;
2931    let message = (error as BusinessError).message;
2932    console.error(`getColorSync failed, error code: ${code}, message: ${message}.`);
2933  }
2934  ```
2935
2936
2937### getColorByNameSync<sup>10+</sup>
2938
2939getColorByNameSync(resName: string) : number
2940
2941Obtains a color value based on the specified resource name. This API returns the result synchronously.
2942
2943**Atomic service API**: This API can be used in atomic services since API version 11.
2944
2945**System capability**: SystemCapability.Global.ResourceManager
2946
2947**Parameters**
2948
2949| Name    | Type    | Mandatory  | Description  |
2950| ------- | ------ | ---- | ---- |
2951| resName | string | Yes   | Resource name.|
2952
2953**Return value**
2954
2955| Type    | Description        |
2956| ------ | ---------- |
2957| number | Color value (decimal) corresponding to the specified resource name.|
2958
2959**Error codes**
2960
2961For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
2962
2963| ID| Error Message|
2964| -------- | ---------------------------------------- |
2965| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
2966| 9001003  | Invalid resource name.                     |
2967| 9001004  | No matching resource is found based on the resource name.       |
2968| 9001006  | The resource is referenced cyclically.            |
2969
2970**Example**
2971  ```json
2972  // Resource file path: src/main/resources/base/element/color.json
2973  {
2974    "color": [
2975      {
2976        "name": "test",
2977        "value": "#FFFFFF"
2978      }
2979    ]
2980  }
2981  ```
2982  ```ts
2983  import { BusinessError } from '@kit.BasicServicesKit';
2984
2985  try {
2986    let colorValue = this.context.resourceManager.getColorByNameSync("test");
2987    console.log(`getColorByNameSync, result: ${colorValue}`);
2988    // Print the output result: getColorByNameSync, result: 4294967295
2989  } catch (error) {
2990    let code = (error as BusinessError).code;
2991    let message = (error as BusinessError).message;
2992    console.error(`getColorByNameSync failed, error code: ${code}, message: ${message}.`);
2993  }
2994  ```
2995
2996### getColor<sup>10+</sup>
2997
2998getColor(resId: number, callback: _AsyncCallback&lt;number&gt;): void
2999
3000Obtains a color value based on the specified resource ID. This API uses an asynchronous callback to return the result.
3001
3002**Atomic service API**: This API can be used in atomic services since API version 11.
3003
3004**System capability**: SystemCapability.Global.ResourceManager
3005
3006**Parameters**
3007
3008| Name     | Type                         | Mandatory  | Description             |
3009| -------- | --------------------------- | ---- | --------------- |
3010| resId    | number                      | Yes   | Resource ID.          |
3011| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;number&gt; | Yes   | Callback used to return the color value (decimal).|
3012
3013**Error codes**
3014
3015For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3016
3017| ID| Error Message|
3018| -------- | ---------------------------------------- |
3019| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3020| 9001001  | If the module resId invalid.             |
3021| 9001002  | No matching resource is found based on the resource ID.      |
3022| 9001006  | The resource is referenced cyclically.         |
3023
3024**Example (stage)**
3025  ```json
3026  // Resource file path: src/main/resources/base/element/color.json
3027  {
3028    "color": [
3029      {
3030        "name": "test",
3031        "value": "#FFFFFF"
3032      }
3033    ]
3034  }
3035  ```
3036  ```ts
3037  import { BusinessError } from '@kit.BasicServicesKit';
3038
3039  this.context.resourceManager.getColor($r('app.color.test').id, (error: BusinessError, value: number) => {
3040    if (error != null) {
3041      console.error(`callback getColor failed, error code: ${error.code}, message: ${error.message}.`);
3042    } else {
3043      console.log(`getColor, result: ${value}`);
3044      // Print the output result: getColor, result: 4294967295
3045    }
3046  });
3047  ```
3048
3049### getColor<sup>10+</sup>
3050
3051getColor(resId: number): Promise&lt;number&gt;
3052
3053Obtains a color value based on the specified resource ID. This API uses a promise to return the result.
3054
3055**Atomic service API**: This API can be used in atomic services since API version 11.
3056
3057**System capability**: SystemCapability.Global.ResourceManager
3058
3059**Parameters**
3060
3061| Name  | Type    | Mandatory  | Description   |
3062| ----- | ------ | ---- | ----- |
3063| resId | number | Yes   | Resource ID.|
3064
3065**Return value**
3066
3067| Type                   | Description         |
3068| --------------------- | ----------- |
3069| Promise&lt;number&gt; | Promise used to return the color value (decimal).|
3070
3071**Error codes**
3072
3073For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3074
3075| ID| Error Message|
3076| -------- | ---------------------------------------- |
3077| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3078| 9001001  | Invalid resource ID.                       |
3079| 9001002  | No matching resource is found based on the resource ID.         |
3080| 9001006  | The resource is referenced cyclically.            |
3081
3082**Example**
3083  ```json
3084  // Resource file path: src/main/resources/base/element/color.json
3085  {
3086    "color": [
3087      {
3088        "name": "test",
3089        "value": "#FFFFFF"
3090      }
3091    ]
3092  }
3093  ```
3094  ```ts
3095  import { BusinessError } from '@kit.BasicServicesKit';
3096
3097  this.context.resourceManager.getColor($r('app.color.test').id)
3098    .then((value: number) => {
3099      console.log(`getColor, result: ${value}`);
3100      // Print the output result: getColor, result: 4294967295
3101    })
3102    .catch((error: BusinessError) => {
3103      console.error(`promise getColor failed, error code: ${error.code}, message: ${error.message}.`);
3104    });
3105  ```
3106
3107
3108### getColorByName<sup>10+</sup>
3109
3110getColorByName(resName: string, callback: _AsyncCallback&lt;number&gt;): void
3111
3112Obtains a color value based on the specified resource name. This API uses an asynchronous callback to return the result.
3113
3114**Atomic service API**: This API can be used in atomic services since API version 11.
3115
3116**System capability**: SystemCapability.Global.ResourceManager
3117
3118**Parameters**
3119
3120| Name     | Type                         | Mandatory  | Description             |
3121| -------- | --------------------------- | ---- | --------------- |
3122| resName  | string                      | Yes   | Resource name.           |
3123| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;number&gt; | Yes   | Callback used to return the color value (decimal).|
3124
3125**Error codes**
3126
3127For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3128
3129| ID| Error Message|
3130| -------- | ---------------------------------------- |
3131| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3132| 9001003  | Invalid resource name.                     |
3133| 9001004  | No matching resource is found based on the resource name.       |
3134| 9001006  | The resource is referenced cyclically.            |
3135
3136**Example**
3137  ```json
3138  // Resource file path: src/main/resources/base/element/color.json
3139  {
3140    "color": [
3141      {
3142        "name": "test",
3143        "value": "#FFFFFF"
3144      }
3145    ]
3146  }
3147  ```
3148  ```ts
3149  import { BusinessError } from '@kit.BasicServicesKit';
3150
3151  this.context.resourceManager.getColorByName("test", (error: BusinessError, value: number) => {
3152    if (error != null) {
3153      console.error(`callback getColorByName failed, error code: ${error.code}, message: ${error.message}.`);
3154    } else {
3155      console.log(`getColorByName, result: ${value}`);
3156      // Print the output result: getColorByName, result: 4294967295
3157    }
3158  });
3159  ```
3160
3161### getColorByName<sup>10+</sup>
3162
3163getColorByName(resName: string): Promise&lt;number&gt;
3164
3165Obtains a color value based on the specified resource name. This API uses a promise to return the result.
3166
3167**Atomic service API**: This API can be used in atomic services since API version 11.
3168
3169**System capability**: SystemCapability.Global.ResourceManager
3170
3171**Parameters**
3172
3173| Name    | Type    | Mandatory  | Description  |
3174| ------- | ------ | ---- | ---- |
3175| resName | string | Yes   | Resource name.|
3176
3177**Return value**
3178
3179| Type                   | Description        |
3180| --------------------- | ---------- |
3181| Promise&lt;number&gt; | Promise used to return the color value (decimal).|
3182
3183**Error codes**
3184
3185For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3186
3187| ID| Error Message|
3188| -------- | ---------------------------------------- |
3189| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3190| 9001003  | Invalid resource name.                     |
3191| 9001004  | No matching resource is found based on the resource name.       |
3192| 9001006  | The resource is referenced cyclically.            |
3193
3194**Example**
3195  ```json
3196  // Resource file path: src/main/resources/base/element/color.json
3197  {
3198    "color": [
3199      {
3200        "name": "test",
3201        "value": "#FFFFFF"
3202      }
3203    ]
3204  }
3205  ```
3206  ```ts
3207  import { BusinessError } from '@kit.BasicServicesKit';
3208
3209  this.context.resourceManager.getColorByName("test")
3210    .then((value: number) => {
3211      console.log(`getColorByName, result: ${value}`);
3212      // Print the output result: getColorByName, result: 4294967295
3213    })
3214    .catch((error: BusinessError) => {
3215      console.error(`promise getColorByName failed, error code: ${error.code}, message: ${error.message}.`);
3216    });
3217  ```
3218
3219### getRawFileContentSync<sup>10+</sup>
3220
3221getRawFileContentSync(path: string): Uint8Array
3222
3223Obtains the content of a raw file in the **resources/rawfile** directory. This API returns the result synchronously.
3224
3225**Atomic service API**: This API can be used in atomic services since API version 11.
3226
3227**System capability**: SystemCapability.Global.ResourceManager
3228
3229**Parameters**
3230
3231| Name     | Type                             | Mandatory  | Description                     |
3232| -------- | ------------------------------- | ---- | ----------------------- |
3233| path     | string                          | Yes   | Path of the raw file.            |
3234
3235**Return value**
3236
3237| Type                   | Description        |
3238| --------------------- | ---------- |
3239| Uint8Array | Content of the raw file.|
3240
3241**Error codes**
3242
3243For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3244
3245| ID| Error Message|
3246| -------- | ---------------------------------------- |
3247| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3248| 9001005  | Invalid relative path.          |
3249
3250**Example**
3251  ```ts
3252  import { BusinessError } from '@kit.BasicServicesKit';
3253
3254  try {
3255    this.context.resourceManager.getRawFileContentSync("test.txt");
3256  } catch (error) {
3257    let code = (error as BusinessError).code;
3258    let message = (error as BusinessError).message;
3259    console.error(`getRawFileContentSync failed, error code: ${code}, message: ${message}.`);
3260  }
3261  ```
3262
3263### getRawFileContent<sup>9+</sup>
3264
3265getRawFileContent(path: string, callback: _AsyncCallback&lt;Uint8Array&gt;): void
3266
3267Obtains the content of a raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
3268
3269**Atomic service API**: This API can be used in atomic services since API version 11.
3270
3271**System capability**: SystemCapability.Global.ResourceManager
3272
3273**Parameters**
3274
3275| Name     | Type                             | Mandatory  | Description                     |
3276| -------- | ------------------------------- | ---- | ----------------------- |
3277| path     | string                          | Yes   | Path of the raw file.            |
3278| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the content of the raw file.|
3279
3280**Error codes**
3281
3282For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3283
3284| ID| Error Message|
3285| -------- | ---------------------------------------- |
3286| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3287| 9001005  | Invalid relative path.          |
3288
3289**Example**
3290  ```ts
3291  import { BusinessError } from '@kit.BasicServicesKit';
3292
3293  try {
3294    this.context.resourceManager.getRawFileContent("test.txt", (error: BusinessError, value: Uint8Array) => {
3295      if (error != null) {
3296        console.error("error is " + error);
3297      } else {
3298        let rawFile = value;
3299      }
3300    });
3301  } catch (error) {
3302    let code = (error as BusinessError).code;
3303    let message = (error as BusinessError).message;
3304    console.error(`callback getRawFileContent failed, error code: ${code}, message: ${message}.`);
3305  }
3306  ```
3307
3308### getRawFileContent<sup>9+</sup>
3309
3310getRawFileContent(path: string): Promise&lt;Uint8Array&gt;
3311
3312Obtains the content of a raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
3313
3314**Atomic service API**: This API can be used in atomic services since API version 11.
3315
3316**System capability**: SystemCapability.Global.ResourceManager
3317
3318**Parameters**
3319
3320| Name | Type    | Mandatory  | Description         |
3321| ---- | ------ | ---- | ----------- |
3322| path | string | Yes   | Path of the raw file.|
3323
3324**Return value**
3325
3326| Type                       | Description         |
3327| ------------------------- | ----------- |
3328| Promise&lt;Uint8Array&gt; | Promise used to return the content of the raw file.|
3329
3330**Error codes**
3331
3332For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3333
3334| ID| Error Message|
3335| -------- | ---------------------------------------- |
3336| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3337| 9001005  | Invalid relative path.          |
3338
3339**Example**
3340  ```ts
3341  import { BusinessError } from '@kit.BasicServicesKit';
3342
3343  try {
3344    this.context.resourceManager.getRawFileContent("test.txt").then((value: Uint8Array) => {
3345      let rawFile = value;
3346    }).catch((error: BusinessError) => {
3347      console.error("getRawFileContent promise error is " + error);
3348    });
3349  } catch (error) {
3350    let code = (error as BusinessError).code;
3351    let message = (error as BusinessError).message;
3352    console.error(`promise getRawFileContent failed, error code: ${code}, message: ${message}.`);
3353  }
3354  ```
3355
3356### getRawFileListSync<sup>10+</sup>
3357
3358getRawFileListSync(path: string): Array\<string>
3359
3360Obtains the list of folders and files in the **resources/rawfile** directory. This API returns the result synchronously.
3361
3362>**NOTE**
3363>
3364> If there is no folder or file in the directory, an exception is thrown. If there are folders and files in the directory, the list of the folders and files is returned.
3365
3366**Atomic service API**: This API can be used in atomic services since API version 11.
3367
3368**System capability**: SystemCapability.Global.ResourceManager
3369
3370**Parameters**
3371
3372| Name     | Type                             | Mandatory  | Description                     |
3373| -------- | ------------------------------- | ---- | ----------------------- |
3374| path     | string                          | Yes   | **rawfile** directory.            |
3375
3376**Return value**
3377
3378| Type                       | Description         |
3379| ------------------------- | ----------- |
3380| Array\<string> | List of folders and files in the **rawfile** directory.|
3381
3382**Error codes**
3383
3384For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3385
3386| ID| Error Message|
3387| -------- | ---------------------------------------- |
3388| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3389| 9001005  | Invalid relative path.       |
3390
3391**Example**
3392  ```ts
3393  import { BusinessError } from '@kit.BasicServicesKit';
3394
3395  try {
3396    // Passing "" means to obtain the list of files in the root directory (that is, /rawfile). Assume that the test.txt file exists in the root directory.
3397    let fileList: Array<string> = this.context.resourceManager.getRawFileListSync("");
3398    console.log(`getRawFileListSync, result: ${JSON.stringify(fileList)}`);
3399    // Print the output result: getRawFileListSync, result: ["test.txt"]
3400  } catch (error) {
3401    let code = (error as BusinessError).code;
3402    let message = (error as BusinessError).message;
3403    console.error(`getRawFileListSync failed, error code: ${code}, message: ${message}.`);
3404  }
3405  ```
3406
3407### getRawFileList<sup>10+</sup>
3408
3409getRawFileList(path: string, callback: _AsyncCallback&lt;Array\<string\>&gt;): void
3410
3411Obtains the list of folders and files in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
3412
3413>**NOTE**
3414>
3415> If there is no folder or file in the directory, an exception is thrown. If there are folders and files in the directory, the list of the folders and files is returned.
3416
3417**Atomic service API**: This API can be used in atomic services since API version 11.
3418
3419**System capability**: SystemCapability.Global.ResourceManager
3420
3421**Parameters**
3422
3423| Name     | Type                             | Mandatory  | Description                     |
3424| -------- | ------------------------------- | ---- | ----------------------- |
3425| path     | string                          | Yes   | **rawfile** directory.            |
3426| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Array\<string\>&gt; | Yes| Callback used to return the list of folders and files.|
3427
3428**Error codes**
3429
3430For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3431
3432| ID| Error Message|
3433| -------- | ---------------------------------------- |
3434| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3435| 9001005  | Invalid relative path.       |
3436
3437**Example**
3438  ```ts
3439  import { BusinessError } from '@kit.BasicServicesKit';
3440
3441  // Passing "" means to obtain the list of files in the root directory (that is, /rawfile). Assume that the test.txt file exists in the root directory.
3442  this.context.resourceManager.getRawFileList("", (error: BusinessError, value: Array<string>) => {
3443    if (error != null) {
3444      console.error(`callback getRawFileList failed, error code: ${error.code}, message: ${error.message}.`);
3445    } else {
3446      console.log(`getRawFileListSync, result: ${JSON.stringify(value)}`);
3447      // Print the output result: getRawFileListSync, result: ["test.txt"]
3448    }
3449  });
3450  ```
3451
3452### getRawFileList<sup>10+</sup>
3453
3454getRawFileList(path: string): Promise&lt;Array\<string\>&gt;
3455
3456Obtains the list of folders and files in the **resources/rawfile** directory. This API uses a promise to return the result.
3457
3458>**NOTE**
3459>
3460> If there is no folder or file in the directory, an exception is thrown. If there are folders and files in the directory, the list of the folders and files is returned.
3461
3462**Atomic service API**: This API can be used in atomic services since API version 11.
3463
3464**System capability**: SystemCapability.Global.ResourceManager
3465
3466**Parameters**
3467
3468| Name | Type    | Mandatory  | Description         |
3469| ---- | ------ | ---- | ----------- |
3470| path | string | Yes   | **rawfile** directory.|
3471
3472**Return value**
3473
3474| Type                       | Description         |
3475| ------------------------- | ----------- |
3476| Promise&lt;Array\<string\>&gt; | Promise used to return the list of folders and files.|
3477
3478**Error codes**
3479
3480For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3481
3482| ID| Error Message|
3483| -------- | ---------------------------------------- |
3484| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3485| 9001005  | Invalid relative path.          |
3486
3487**Example**
3488  ```ts
3489  import { BusinessError } from '@kit.BasicServicesKit';
3490
3491  // Passing "" means to obtain the list of files in the root directory (that is, /rawfile). Assume that the test.txt file exists in the root directory.
3492  this.context.resourceManager.getRawFileList("")
3493    .then((value: Array<string>) => {
3494      console.log(`getRawFileListSync, result: ${JSON.stringify(value)}`);
3495      // Print the output result: getRawFileListSync, result: ["test.txt"]
3496    })
3497    .catch((error: BusinessError) => {
3498      console.error(`promise getRawFileList failed, error code: ${error.code}, message: ${error.message}.`);
3499    });
3500  ```
3501
3502### getRawFdSync<sup>10+</sup>
3503
3504getRawFdSync(path: string): RawFileDescriptor
3505
3506Obtains the fd of the HAP where a specific raw file in the **resources/rawfile** directory is located.
3507
3508> **NOTE**
3509>
3510> To prevent resource leakage, call [closeRawFdSync](#closerawfdsync10) or [closeRawFd](#closerawfd9) to close the fd after use.
3511
3512**Atomic service API**: This API can be used in atomic services since API version 11.
3513
3514**System capability**: SystemCapability.Global.ResourceManager
3515
3516**Parameters**
3517
3518| Name     | Type                                      | Mandatory  | Description                              |
3519| -------- | ---------------------------------------- | ---- | -------------------------------- |
3520| path     | string                                   | Yes   | Path of the raw file.                    |
3521
3522**Return value**
3523
3524| Type                       | Description         |
3525| ------------------------- | ----------- |
3526| [RawFileDescriptor](#rawfiledescriptor9) | fd of the HAP where the raw file is located.|
3527
3528**Error codes**
3529
3530For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3531
3532| ID| Error Message|
3533| -------- | ---------------------------------------- |
3534| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3535| 9001005  | Invalid relative path.          |
3536
3537**Example**
3538  ```ts
3539  import { BusinessError } from '@kit.BasicServicesKit';
3540
3541  try {
3542    this.context.resourceManager.getRawFdSync("test.txt");
3543  } catch (error) {
3544    let code = (error as BusinessError).code;
3545    let message = (error as BusinessError).message;
3546    console.error(`getRawFdSync failed, error code: ${code}, message: ${message}.`);
3547  }
3548  ```
3549
3550### getRawFd<sup>9+</sup>
3551
3552getRawFd(path: string, callback: _AsyncCallback&lt;RawFileDescriptor&gt;): void
3553
3554Obtains the fd of the HAP where a specific raw file in the **resources/rawfile** directory is located.
3555
3556> **NOTE**
3557>
3558> To prevent resource leakage, call [closeRawFdSync](#closerawfdsync10) or [closeRawFd](#closerawfd9) to close the fd after use.
3559
3560**Atomic service API**: This API can be used in atomic services since API version 11.
3561
3562**System capability**: SystemCapability.Global.ResourceManager
3563
3564**Parameters**
3565
3566| Name     | Type                                      | Mandatory  | Description                              |
3567| -------- | ---------------------------------------- | ---- | -------------------------------- |
3568| path     | string                                   | Yes   | Path of the raw file.                     |
3569| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;[RawFileDescriptor](#rawfiledescriptor9)&gt; | Yes   | Callback used to return the fd of the HAP.|
3570
3571**Error codes**
3572
3573For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3574
3575| ID| Error Message|
3576| -------- | ---------------------------------------- |
3577| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3578| 9001005  | Invalid relative path.          |
3579
3580**Example**
3581  ```ts
3582  import { BusinessError } from '@kit.BasicServicesKit';
3583  import { resourceManager } from '@kit.LocalizationKit';
3584
3585  try {
3586    this.context.resourceManager.getRawFd("test.txt", (error: BusinessError, value: resourceManager.RawFileDescriptor) => {
3587      if (error != null) {
3588        console.error(`callback getRawFd failed error code: ${error.code}, message: ${error.message}.`);
3589      } else {
3590        let fd = value.fd;
3591        let offset = value.offset;
3592        let length = value.length;
3593      }
3594    });
3595  } catch (error) {
3596    let code = (error as BusinessError).code;
3597    let message = (error as BusinessError).message;
3598    console.error(`callback getRawFd failed, error code: ${code}, message: ${message}.`);
3599  }
3600  ```
3601
3602### getRawFd<sup>9+</sup>
3603
3604getRawFd(path: string): Promise&lt;RawFileDescriptor&gt;
3605
3606Obtains the fd of the HAP where a specific raw file in the **resources/rawfile** directory is located.
3607
3608> **NOTE**
3609>
3610> To prevent resource leakage, call [closeRawFdSync](#closerawfdsync10) or [closeRawFd](#closerawfd9) to close the fd after use.
3611
3612**Atomic service API**: This API can be used in atomic services since API version 11.
3613
3614**System capability**: SystemCapability.Global.ResourceManager
3615
3616**Parameters**
3617
3618| Name | Type    | Mandatory  | Description         |
3619| ---- | ------ | ---- | ----------- |
3620| path | string | Yes   | Path of the raw file.|
3621
3622**Return value**
3623
3624| Type                                      | Description                 |
3625| ---------------------------------------- | ------------------- |
3626| Promise&lt;[RawFileDescriptor](#rawfiledescriptor9)&gt; | Promise used to return the fd of the HAP.|
3627
3628**Error codes**
3629
3630For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3631
3632| ID| Error Message|
3633| -------- | ---------------------------------------- |
3634| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3635| 9001005  | Invalid relative path.          |
3636
3637**Example**
3638  ```ts
3639  import { BusinessError } from '@kit.BasicServicesKit';
3640  import { resourceManager } from '@kit.LocalizationKit';
3641
3642  try {
3643    this.context.resourceManager.getRawFd("test.txt").then((value: resourceManager.RawFileDescriptor) => {
3644      let fd = value.fd;
3645      let offset = value.offset;
3646      let length = value.length;
3647    }).catch((error: BusinessError) => {
3648      console.error(`promise getRawFd error error code: ${error.code}, message: ${error.message}.`);
3649    });
3650  } catch (error) {
3651    let code = (error as BusinessError).code;
3652    let message = (error as BusinessError).message;
3653    console.error(`promise getRawFd failed, error code: ${code}, message: ${message}.`);
3654  }
3655  ```
3656
3657### closeRawFdSync<sup>10+</sup>
3658
3659closeRawFdSync(path: string): void
3660
3661Closes the fd of the HAP where a specific raw file in the **resources/rawfile** directory is located.
3662
3663**Atomic service API**: This API can be used in atomic services since API version 11.
3664
3665**System capability**: SystemCapability.Global.ResourceManager
3666
3667**Parameters**
3668
3669| Name     | Type                       | Mandatory  | Description         |
3670| -------- | ------------------------- | ---- | ----------- |
3671| path     | string                    | Yes   | Path of the raw file.|
3672
3673**Error codes**
3674
3675For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3676
3677| ID| Error Message|
3678| -------- | ---------------------------------------- |
3679| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3680| 9001005  | The resource not found by path.          |
3681
3682**Example**
3683  ```ts
3684  import { BusinessError } from '@kit.BasicServicesKit';
3685
3686  try {
3687    this.context.resourceManager.closeRawFdSync("test.txt");
3688  } catch (error) {
3689    let code = (error as BusinessError).code;
3690    let message = (error as BusinessError).message;
3691    console.error(`closeRawFd failed, error code: ${code}, message: ${message}.`);
3692  }
3693  ```
3694
3695### closeRawFd<sup>9+</sup>
3696
3697closeRawFd(path: string, callback: _AsyncCallback&lt;void&gt;): void
3698
3699Closes the fd of the HAP where a specific raw file in the **resources/rawfile** directory is located. This API uses an asynchronous callback to return the result.
3700
3701**Atomic service API**: This API can be used in atomic services since API version 11.
3702
3703**System capability**: SystemCapability.Global.ResourceManager
3704
3705**Parameters**
3706
3707| Name     | Type                       | Mandatory  | Description         |
3708| -------- | ------------------------- | ---- | ----------- |
3709| path     | string                    | Yes   | Path of the raw file.|
3710| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;void&gt; | Yes   | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
3711
3712**Error codes**
3713
3714For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3715
3716| ID| Error Message|
3717| -------- | ---------------------------------------- |
3718| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3719| 9001005  | The resource not found by path.          |
3720
3721**Example**
3722  ```ts
3723  import { BusinessError } from '@kit.BasicServicesKit';
3724
3725  try {
3726    this.context.resourceManager.closeRawFd("test.txt", (error: BusinessError) => {
3727      if (error != null) {
3728        console.error("error is " + error);
3729      }
3730    });
3731  } catch (error) {
3732    let code = (error as BusinessError).code;
3733    let message = (error as BusinessError).message;
3734    console.error(`callback closeRawFd failed, error code: ${code}, message: ${message}.`);
3735  }
3736  ```
3737
3738### closeRawFd<sup>9+</sup>
3739
3740closeRawFd(path: string): Promise&lt;void&gt;
3741
3742Closes the fd of the HAP where a specific raw file in the **resources/rawfile** directory is located. This API uses a promise to return the result.
3743
3744**Atomic service API**: This API can be used in atomic services since API version 11.
3745
3746**System capability**: SystemCapability.Global.ResourceManager
3747
3748**Parameters**
3749
3750| Name | Type    | Mandatory  | Description         |
3751| ---- | ------ | ---- | ----------- |
3752| path | string | Yes   | Path of the raw file.|
3753
3754**Return value**
3755
3756| Type                 | Description  |
3757| ------------------- | ---- |
3758| Promise&lt;void&gt; | Promise that returns no value.|
3759
3760**Error codes**
3761
3762For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3763
3764| ID| Error Message|
3765| -------- | ---------------------------------------- |
3766| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3767| 9001005  | Invalid relative path.          |
3768
3769**Example**
3770  ```ts
3771  import { BusinessError } from '@kit.BasicServicesKit';
3772
3773  try {
3774    this.context.resourceManager.closeRawFd("test.txt");
3775  } catch (error) {
3776    let code = (error as BusinessError).code;
3777    let message = (error as BusinessError).message;
3778    console.error(`promise closeRawFd failed, error code: ${code}, message: ${message}.`);
3779  }
3780  ```
3781
3782### getConfigurationSync<sup>10+</sup>
3783
3784getConfigurationSync(): Configuration
3785
3786Obtains the device configuration. This API returns the result synchronously.
3787
3788**Atomic service API**: This API can be used in atomic services since API version 11.
3789
3790**System capability**: SystemCapability.Global.ResourceManager
3791
3792**Return value**
3793
3794| Type                                      | Description              |
3795| ---------------------------------------- | ---------------- |
3796| [Configuration](#configuration) | Device configuration.|
3797
3798**Example**
3799  ```ts
3800  try {
3801    let value = this.context.resourceManager.getConfigurationSync();
3802    let direction = value.direction;
3803    let locale = value.locale;
3804  } catch (error) {
3805    console.error("getConfigurationSync error is " + error);
3806  }
3807  ```
3808
3809### getConfiguration
3810
3811getConfiguration(callback: _AsyncCallback&lt;Configuration&gt;): void
3812
3813Obtains the device configuration. This API uses an asynchronous callback to return the result.
3814
3815**Atomic service API**: This API can be used in atomic services since API version 11.
3816
3817**System capability**: SystemCapability.Global.ResourceManager
3818
3819**Parameters**
3820
3821| Name     | Type                                      | Mandatory  | Description                       |
3822| -------- | ---------------------------------------- | ---- | ------------------------- |
3823| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;[Configuration](#configuration)&gt; | Yes   | Callback used to return the device configuration.|
3824
3825**Example**
3826  ```ts
3827  import { resourceManager } from '@kit.LocalizationKit';
3828
3829  try {
3830    this.context.resourceManager.getConfiguration((error: BusinessError, value: resourceManager.Configuration) => {
3831      if (error != null) {
3832        console.error("getConfiguration callback error is " + error);
3833      } else {
3834        let direction = value.direction;
3835        let locale = value.locale;
3836      }
3837    });
3838  } catch (error) {
3839    console.error("getConfiguration callback error is " + error);
3840  }
3841  ```
3842
3843### getConfiguration
3844
3845getConfiguration(): Promise&lt;Configuration&gt;
3846
3847Obtains the device configuration. This API uses a promise to return the result.
3848
3849**Atomic service API**: This API can be used in atomic services since API version 11.
3850
3851**System capability**: SystemCapability.Global.ResourceManager
3852
3853**Return value**
3854
3855| Type                                      | Description              |
3856| ---------------------------------------- | ---------------- |
3857| Promise&lt;[Configuration](#configuration)&gt; | Promise used to return the device configuration.|
3858
3859**Example**
3860  ```ts
3861  import { BusinessError } from '@kit.BasicServicesKit';
3862  import { resourceManager } from '@kit.LocalizationKit';
3863
3864  try {
3865    this.context.resourceManager.getConfiguration().then((value: resourceManager.Configuration) => {
3866      let direction = value.direction;
3867      let locale = value.locale;
3868    }).catch((error: BusinessError) => {
3869      console.error("getConfiguration promise error is " + error);
3870    });
3871  } catch (error) {
3872    console.error("getConfiguration promise error is " + error);
3873  }
3874  ```
3875
3876### getDeviceCapabilitySync<sup>10+</sup>
3877
3878getDeviceCapabilitySync(): DeviceCapability
3879
3880Obtains the device capability. This API returns the result synchronously.
3881
3882**Atomic service API**: This API can be used in atomic services since API version 11.
3883
3884**System capability**: SystemCapability.Global.ResourceManager
3885
3886**Return value**
3887
3888| Type                                      | Description                 |
3889| ---------------------------------------- | ------------------- |
3890| [DeviceCapability](#devicecapability) | Device capability.|
3891
3892**Example**
3893  ```ts
3894  try {
3895    let value = this.context.resourceManager.getDeviceCapabilitySync();
3896    let screenDensity = value.screenDensity;
3897    let deviceType = value.deviceType;
3898  } catch (error) {
3899    console.error("getDeviceCapabilitySync error is " + error);
3900  }
3901  ```
3902
3903### getDeviceCapability
3904
3905getDeviceCapability(callback: _AsyncCallback&lt;DeviceCapability&gt;): void
3906
3907Obtains the device capability. This API uses an asynchronous callback to return the result.
3908
3909**Atomic service API**: This API can be used in atomic services since API version 11.
3910
3911**System capability**: SystemCapability.Global.ResourceManager
3912
3913**Parameters**
3914
3915| Name     | Type                                      | Mandatory  | Description                          |
3916| -------- | ---------------------------------------- | ---- | ---------------------------- |
3917| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;[DeviceCapability](#devicecapability)&gt; | Yes   | Callback used to return the device capability.|
3918
3919**Example**
3920  ```ts
3921  import { resourceManager } from '@kit.LocalizationKit';
3922
3923  try {
3924    this.context.resourceManager.getDeviceCapability((error: BusinessError, value: resourceManager.DeviceCapability) => {
3925      if (error != null) {
3926        console.error("getDeviceCapability callback error is " + error);
3927      } else {
3928        let screenDensity = value.screenDensity;
3929        let deviceType = value.deviceType;
3930      }
3931    });
3932  } catch (error) {
3933    console.error("getDeviceCapability callback error is " + error);
3934  }
3935  ```
3936
3937### getDeviceCapability
3938
3939getDeviceCapability(): Promise&lt;DeviceCapability&gt;
3940
3941Obtains the device capability. This API uses a promise to return the result.
3942
3943**Atomic service API**: This API can be used in atomic services since API version 11.
3944
3945**System capability**: SystemCapability.Global.ResourceManager
3946
3947**Return value**
3948
3949| Type                                      | Description                 |
3950| ---------------------------------------- | ------------------- |
3951| Promise&lt;[DeviceCapability](#devicecapability)&gt; | Promise used to return the device capability.|
3952
3953**Example**
3954  ```ts
3955  import { BusinessError } from '@kit.BasicServicesKit';
3956  import { resourceManager } from '@kit.LocalizationKit';
3957
3958  try {
3959    this.context.resourceManager.getDeviceCapability().then((value: resourceManager.DeviceCapability) => {
3960      let screenDensity = value.screenDensity;
3961      let deviceType = value.deviceType;
3962    }).catch((error: BusinessError) => {
3963      console.error("getDeviceCapability promise error is " + error);
3964    });
3965  } catch (error) {
3966    console.error("getDeviceCapability promise error is " + error);
3967  }
3968  ```
3969
3970### addResource<sup>10+</sup>
3971
3972addResource(path: string): void
3973
3974Loads resources from the specified path.
3975
3976> **NOTE**
3977>
3978> Resource overwriting is not supported for the **/rawfile** and **/resfile** directories.
3979
3980**Atomic service API**: This API can be used in atomic services since API version 11.
3981
3982**System capability**: SystemCapability.Global.ResourceManager
3983
3984**Parameters**
3985
3986| Name     | Type                    | Mandatory  | Description  |
3987| -------- | ---------------------- | ---- | ---- |
3988| path | string | Yes   | Resource path.|
3989
3990**Error codes**
3991
3992For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
3993
3994| ID| Error Message|
3995| -------- | ---------------------------------------- |
3996| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
3997| 9001010  | Invalid overlay path.            |
3998
3999**Example**
4000  ```ts
4001  import { BusinessError } from '@kit.BasicServicesKit';
4002
4003  let path = this.context.bundleCodeDir + "/library1-default-signed.hsp";
4004  try {
4005    this.context.resourceManager.addResource(path);
4006  } catch (error) {
4007    let code = (error as BusinessError).code;
4008    let message = (error as BusinessError).message;
4009    console.error(`addResource failed, error code: ${code}, message: ${message}.`);
4010  }
4011  ```
4012
4013### removeResource<sup>10+</sup>
4014
4015removeResource(path: string): void
4016
4017Removes the resources loaded from the specified path to restore the original resources.
4018
4019> **NOTE**
4020>
4021> Resource overwriting is not supported for the **/rawfile** and **/resfile** directories.
4022
4023**Atomic service API**: This API can be used in atomic services since API version 11.
4024
4025**System capability**: SystemCapability.Global.ResourceManager
4026
4027**Parameters**
4028
4029| Name     | Type           | Mandatory  | Description  |
4030| -------- | ---------------------- | ---- | ---- |
4031| path | string | Yes   | Resource path.|
4032
4033**Error codes**
4034
4035For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4036
4037| ID| Error Message|
4038| -------- | ---------------------------------------- |
4039| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4040| 9001010  | Invalid overlay path.            |
4041
4042**Example**
4043  ```ts
4044  import { BusinessError } from '@kit.BasicServicesKit';
4045
4046  let path = this.context.bundleCodeDir + "/library1-default-signed.hsp";
4047  try {
4048    this.context.resourceManager.removeResource(path);
4049  } catch (error) {
4050    let code = (error as BusinessError).code;
4051    let message = (error as BusinessError).message;
4052    console.error(`removeResource failed, error code: ${code}, message: ${message}.`);
4053  }
4054  ```
4055
4056### getLocales<sup>11+</sup>
4057
4058getLocales(includeSystem?: boolean): Array\<string>
4059
4060Obtains the language list of an application.
4061
4062**Atomic service API**: This API can be used in atomic services since API version 11.
4063
4064**System capability**: SystemCapability.Global.ResourceManager
4065
4066**Parameters**
4067
4068| Name        | Type   | Mandatory  | Description      |
4069| -------------- | ------- | ------ | -------------------- |
4070| includeSystem  | boolean |  No   | Whether system resources are included. The default value is **false**.<br> - **false**: Only application resources are included.<br> - **true**: Both system and application resources are included.<br>If the value of **includeSystem** is invalid, the language list of system resources will be returned.|
4071
4072**Return value**
4073
4074| Type                       | Description         |
4075| ------------------------- | ----------- |
4076| Array\<string> | Language list. The strings in the list are comprised of the language, script (optional), and region (optional), which are connected by a hyphen (-).|
4077
4078**Example**
4079  ```ts
4080  import { resourceManager } from '@kit.LocalizationKit';
4081  import { BusinessError } from '@kit.BasicServicesKit';
4082
4083  try {
4084    this.context.resourceManager.getLocales(); // Obtain only the language list of application resources.
4085  } catch (error) {
4086    let code = (error as BusinessError).code;
4087    let message = (error as BusinessError).message;
4088    console.error(`getLocales failed, error code: ${code}, message: ${message}.`);
4089  }
4090
4091  try {
4092    resourceManager.getSysResourceManager().getLocales(); // Obtain only the language list of system resources.
4093  } catch (error) {
4094    let code = (error as BusinessError).code;
4095    let message = (error as BusinessError).message;
4096    console.error(`getLocales failed, error code: ${code}, message: ${message}.`);
4097  }
4098
4099  try {
4100    this.context.resourceManager.getLocales(true); // Obtain the language list of application resources and resources.
4101  } catch (error) {
4102    let code = (error as BusinessError).code;
4103    let message = (error as BusinessError).message;
4104    console.error(`getLocales failed, error code: ${code}, message: ${message}.`);
4105  }
4106  ```
4107
4108### getSymbol<sup>11+</sup>
4109
4110getSymbol(resId: number): number
4111
4112Obtains the Unicode of a [symbol](https://developer.huawei.com/consumer/en/design/harmonyos-symbol) based on the specified resource ID. This API returns the result synchronously.
4113
4114**Atomic service API**: This API can be used in atomic services since API version 11.
4115
4116**System capability**: SystemCapability.Global.ResourceManager
4117
4118**Parameters**
4119
4120| Name  | Type    | Mandatory  | Description   |
4121| ----- | ------ | ---- | ----- |
4122| resId | number | Yes   | Resource ID.|
4123
4124**Return value**
4125
4126| Type    | Description         |
4127| ------ | ----------- |
4128| number | Unicode code (decimal) of the symbol.|
4129
4130**Error codes**
4131
4132For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4133
4134| ID| Error Message|
4135| -------- | ---------------------------------------- |
4136| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4137| 9001001  | Invalid resource ID.                       |
4138| 9001002  | No matching resource is found based on the resource ID.         |
4139| 9001006  | The resource is referenced cyclically.            |
4140
4141**Example**
4142  ```ts
4143  import { BusinessError } from '@kit.BasicServicesKit';
4144
4145  try {
4146    let symbolValue = this.context.resourceManager.getSymbol($r('sys.symbol.message').id);
4147    console.log(`getSymbol, result: ${symbolValue}`);
4148    // Print the output result: getSymbol, result: 983183
4149  } catch (error) {
4150    let code = (error as BusinessError).code;
4151    let message = (error as BusinessError).message;
4152    console.error(`getSymbol failed, error code: ${code}, message: ${message}.`);
4153  }
4154  ```
4155
4156
4157### getSymbolByName<sup>11+</sup>
4158
4159getSymbolByName(resName: string): number
4160
4161Obtains the Unicode of a [symbol](https://developer.huawei.com/consumer/en/design/harmonyos-symbol) based on the specified resource name. This API returns the result synchronously.
4162
4163**Atomic service API**: This API can be used in atomic services since API version 11.
4164
4165**System capability**: SystemCapability.Global.ResourceManager
4166
4167**Parameters**
4168
4169| Name    | Type    | Mandatory  | Description  |
4170| ------- | ------ | ---- | ---- |
4171| resName | string | Yes   | Resource name.|
4172
4173**Return value**
4174
4175| Type    | Description        |
4176| ------ | ---------- |
4177| number | Unicode code (decimal) of the symbol.|
4178
4179**Error codes**
4180
4181For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4182
4183| ID| Error Message|
4184| -------- | ---------------------------------------- |
4185| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4186| 9001003  | Invalid resource name.                     |
4187| 9001004  | No matching resource is found based on the resource name.       |
4188| 9001006  | The resource is referenced cyclically.            |
4189
4190**Example**
4191  ```ts
4192  import { BusinessError } from '@kit.BasicServicesKit';
4193
4194  try {
4195    let symbolValue = this.context.resourceManager.getSymbolByName("message");
4196    console.log(`getSymbolByName, result: ${symbolValue}`);
4197    // Print the output result: getSymbolByName, result: 983183
4198  } catch (error) {
4199    let code = (error as BusinessError).code;
4200    let message = (error as BusinessError).message;
4201    console.error(`getSymbolByName failed, error code: ${code}, message: ${message}.`);
4202  }
4203  ```
4204
4205### isRawDir<sup>12+</sup>
4206
4207isRawDir(path: string): boolean
4208
4209Checks whether a path is a subdirectory in the **rawfile** directory. This API returns the result synchronously.
4210
4211**Atomic service API**: This API can be used in atomic services since API version 12.
4212
4213**System capability**: SystemCapability.Global.ResourceManager
4214
4215**Parameters**
4216
4217| Name    | Type    | Mandatory  | Description  |
4218| ------- | ------ | ---- | ---- |
4219| path | string | Yes   | Path of a raw file.|
4220
4221**Return value**
4222
4223| Type    | Description        |
4224| ------ | ---------- |
4225| boolean |Whether the path is a subdirectory in the **rawfile** directory.<br> - **true**: The path is a subdirectory in the **rawfile** directory.<br> - **false**: The path is not a subdirectory in the **rawfile** directory.|
4226
4227**Error codes**
4228
4229For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4230
4231| ID| Error Message|
4232| -------- | ---------------------------------------- |
4233| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4234| 9001005  | Invalid relative path.          |
4235
4236**Example**
4237  ```ts
4238  import { BusinessError } from '@kit.BasicServicesKit';
4239
4240  try {
4241    // Assume that a non-empty folder named sub exists in the root directory (that is, /rawfile). The value of isRawDir is true in the return result.
4242    let isRawDir = this.context.resourceManager.isRawDir("sub");
4243    // Print the output result: sub isRawDir, result: true
4244    console.log(`sub isRawDir, result: ${isRawDir}`);
4245
4246    // If the test.txt file exists in the root directory, the value of isRawDir is false.
4247    isRawDir = this.context.resourceManager.isRawDir("test.txt");
4248    // Print the output result: test.txt isRawDir, result: false
4249    console.log(`test.txt isRawDir, result: ${isRawDir}`);
4250  } catch (error) {
4251    let code = (error as BusinessError).code;
4252    let message = (error as BusinessError).message;
4253    console.error(`isRawDir failed, error code: ${code}, message: ${message}.`);
4254  }
4255  ```
4256
4257### getOverrideResourceManager<sup>12+</sup>
4258
4259getOverrideResourceManager(configuration?: Configuration): ResourceManager
4260
4261Obtains a **ResourceManager** object for loading differentiated resources. This API returns the result synchronously.
4262
4263The resource configuration (including the language, color mode, resolution, and orientation) obtained by a common **ResourceManager** object is determined by the system. With this API, an application can obtain resources of the specified configuration (that is, differentiated resources), for example, dark color resources in light color mode.
4264
4265**Atomic service API**: This API can be used in atomic services since API version 12.
4266
4267**System capability**: SystemCapability.Global.ResourceManager
4268
4269**Parameters**
4270
4271| Name       | Type                           | Mandatory| Description                                                        |
4272| ------------- | ------------------------------- | ---- | ------------------------------------------------------------ |
4273| configuration | [Configuration](#configuration) | No  | Resource configuration.<br>After obtaining the configuration of differentiated resources through [getOverrideConfiguration](#getoverrideconfiguration12), modify the configuration items as required, and then pass these items as input parameters to the API.<br>If no configuration is specified, the current system configuration is used.|
4274
4275**Return value**
4276
4277| Type           | Description                              |
4278| --------------- | ---------------------------------- |
4279| ResourceManager | **ResourceManager** object for loading differentiated resources.|
4280
4281**Error codes**
4282
4283For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4284
4285| ID| Error Message                                                    |
4286| -------- | ------------------------------------------------------------ |
4287| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types |
4288
4289**Example**
4290
4291  ```ts
4292  import { BusinessError } from '@kit.BasicServicesKit';
4293  import { resourceManager } from '@kit.LocalizationKit';
4294
4295  try {
4296    let resMgr = this.context.resourceManager;
4297    let overrideConfig = resMgr.getOverrideConfiguration();
4298    overrideConfig.colorMode = resourceManager.ColorMode.DARK;
4299    let overrideResMgr = resMgr.getOverrideResourceManager(overrideConfig);
4300  } catch (error) {
4301    let code = (error as BusinessError).code;
4302    let message = (error as BusinessError).message;
4303    console.error(`getOverrideResourceManager failed, error code: ${code}, message: ${message}.`);
4304  }
4305  ```
4306
4307### getOverrideConfiguration<sup>12+</sup>
4308
4309getOverrideConfiguration(): Configuration
4310
4311Obtains the configuration of differentiated resources. This API returns the result synchronously. This API allows a common **ResourceManager** object and a **ResourceManager** object obtained through [getOverrideResourceManager](#getoverrideresourcemanager12) to obtain the configuration of differentiated resources.
4312
4313**Atomic service API**: This API can be used in atomic services since API version 12.
4314
4315**System capability**: SystemCapability.Global.ResourceManager
4316
4317**Return value**
4318
4319| Type                           | Description            |
4320| ------------------------------- | ---------------- |
4321| [Configuration](#configuration) | Configuration of differentiated resources.|
4322
4323**Example**
4324
4325  ```ts
4326  import { BusinessError } from '@kit.BasicServicesKit';
4327  import { resourceManager } from '@kit.LocalizationKit';
4328
4329  try {
4330    let resMgr = this.context.resourceManager;
4331    let overrideConfig = resMgr.getOverrideConfiguration();
4332    overrideConfig.colorMode = resourceManager.ColorMode.DARK;
4333    let overrideResMgr = resMgr.getOverrideResourceManager(overrideConfig);
4334  } catch (error) {
4335    let code = (error as BusinessError).code;
4336    let message = (error as BusinessError).message;
4337    console.error(`getOverrideResourceManager failed, error code: ${code}, message: ${message}.`);
4338  }
4339  ```
4340
4341### updateOverrideConfiguration<sup>12+</sup>
4342
4343updateOverrideConfiguration(configuration: Configuration): void
4344
4345Updated configuration of differentiated resources. This API allows a common **ResourceManager** object and a **ResourceManager** object obtained through [getOverrideResourceManager](#getoverrideresourcemanager12) to update the configuration of differentiated resources.
4346
4347**Atomic service API**: This API can be used in atomic services since API version 12.
4348
4349**System capability**: SystemCapability.Global.ResourceManager
4350
4351**Parameters**
4352
4353| Name       | Type                           | Mandatory| Description                                                        |
4354| ------------- | ------------------------------- | ---- | ------------------------------------------------------------ |
4355| configuration | [Configuration](#configuration) | Yes  | Configuration of differentiated resources. After obtaining the configuration of differentiated resources through [getOverrideConfiguration](#getoverrideconfiguration12), modify the configuration items as required, and then pass these items as input parameters to the API.|
4356
4357**Error codes**
4358
4359For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
4360
4361| ID| Error Message                                                    |
4362| -------- | ------------------------------------------------------------ |
4363| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types |
4364
4365**Example**
4366
4367  ```ts
4368  import { BusinessError } from '@kit.BasicServicesKit';
4369  import { resourceManager } from '@kit.LocalizationKit';
4370
4371  try {
4372    let resMgr = this.context.resourceManager;
4373    let overrideConfig = resMgr.getOverrideConfiguration();
4374    overrideConfig.colorMode = resourceManager.ColorMode.DARK;
4375    let overrideResMgr = resMgr.updateOverrideConfiguration(overrideConfig);
4376  } catch (error) {
4377    let code = (error as BusinessError).code;
4378    let message = (error as BusinessError).message;
4379    console.error(`updateOverrideConfiguration failed, error code: ${code}, message: ${message}.`);
4380  }
4381  ```
4382
4383### release<sup>(deprecated)</sup>
4384
4385release()
4386
4387Releases a **ResourceManager** object. This API is not supported currently.
4388
4389> **NOTE**
4390>
4391> This API is supported since API version 7 and is deprecated since API version 12.
4392
4393**Atomic service API**: This API can be used in atomic services since API version 11.
4394
4395**System capability**: SystemCapability.Global.ResourceManager
4396
4397**Example**
4398  ```ts
4399  try {
4400    this.context.resourceManager.release();
4401  } catch (error) {
4402    console.error("release error is " + error);
4403  }
4404  ```
4405
4406### getString<sup>(deprecated)</sup>
4407
4408getString(resId: number, callback: AsyncCallback&lt;string&gt;): void
4409
4410Obtains a string based on the specified resource ID. This API uses an asynchronous callback to return the result.
4411
4412> **NOTE**
4413>
4414> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getStringValue](#getstringvalue9).
4415
4416**System capability**: SystemCapability.Global.ResourceManager
4417
4418**Parameters**
4419
4420| Name     | Type                         | Mandatory  | Description             |
4421| -------- | --------------------------- | ---- | --------------- |
4422| resId    | number                      | Yes   | Resource ID.          |
4423| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;string&gt; | Yes   | Callback used to return the obtained string.|
4424
4425**Example**
4426  ```ts
4427  resourceManager.getResourceManager((error, mgr) => {
4428      mgr.getString($r('app.string.test').id, (error: Error, value: string) => {
4429          if (error != null) {
4430              console.error("error is " + error);
4431          } else {
4432              let str = value;
4433          }
4434      });
4435  });
4436  ```
4437
4438
4439### getString<sup>(deprecated)</sup>
4440
4441getString(resId: number): Promise&lt;string&gt;
4442
4443Obtains a string based on the specified resource ID. This API uses a promise to return the result.
4444
4445> **NOTE**
4446>
4447> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getStringValue](#getstringvalue9-1).
4448
4449**System capability**: SystemCapability.Global.ResourceManager
4450
4451**Parameters**
4452
4453| Name  | Type    | Mandatory  | Description   |
4454| ----- | ------ | ---- | ----- |
4455| resId | number | Yes   | Resource ID.|
4456
4457**Return value**
4458
4459| Type                   | Description         |
4460| --------------------- | ----------- |
4461| Promise&lt;string&gt; | Promise used to return the obtained string.|
4462
4463**Example**
4464  ```ts
4465  import { BusinessError } from '@kit.BasicServicesKit';
4466
4467  resourceManager.getResourceManager((error, mgr) => {
4468      mgr.getString($r('app.string.test').id).then((value: string) => {
4469          let str = value;
4470      }).catch((error: BusinessError) => {
4471          console.error("getstring promise error is " + error);
4472      });
4473  });
4474  ```
4475### getStringSync<sup>(deprecated)</sup>
4476
4477getStringSync(resource: Resource): string
4478
4479Obtains a string based on the specified resource object. This API returns the result synchronously.
4480
4481> **NOTE**
4482>
4483> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getStringByNameSync](#getstringbynamesync9) or [getStringSync](#getstringsync9) instead.
4484
4485**Atomic service API**: This API can be used in atomic services since API version 11.
4486
4487**System capability**: SystemCapability.Global.ResourceManager
4488
4489**Model restriction**: This API can be used only in the stage model.
4490
4491**Parameters**
4492
4493| Name     | Type                    | Mandatory  | Description  |
4494| -------- | ---------------------- | ---- | ---- |
4495| resource | [Resource](#resource9) | Yes   | Resource object.|
4496
4497**Return value**
4498
4499| Type    | Description              |
4500| ------ | ---------------- |
4501| string | String corresponding to the specified resource object.|
4502
4503**Error codes**
4504
4505For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4506
4507| ID| Error Message|
4508| -------- | ---------------------------------------- |
4509| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4510| 9001001  | Invalid resource ID.                       |
4511| 9001002  | No matching resource is found based on the resource ID.         |
4512| 9001006  | The resource is referenced cyclically.            |
4513
4514**Example**
4515  ```json
4516  // Resource file path: src/main/resources/base/element/string.json
4517  {
4518    "string": [
4519      {
4520        "name": "test",
4521        "value": "I'm a test string resource."
4522      }
4523    ]
4524  }
4525  ```
4526  ```ts
4527  import { resourceManager } from '@kit.LocalizationKit';
4528  import { BusinessError } from '@kit.BasicServicesKit';
4529
4530  let resource: resourceManager.Resource = {
4531    bundleName: "com.example.myapplication",
4532    moduleName: "entry",
4533    id: $r('app.string.test').id
4534  };
4535  try {
4536    let testStr = this.context.resourceManager.getStringSync(resource);
4537    console.log(`getStringSync, result: ${testStr}`);
4538    // Print the output result: getStringSync, result: I'm a test string resource.
4539  } catch (error) {
4540    let code = (error as BusinessError).code;
4541    let message = (error as BusinessError).message;
4542    console.error(`getStringSync failed, error code: ${code}, message: ${message}.`);
4543  }
4544  ```
4545
4546### getStringSync<sup>(deprecated)</sup>
4547
4548getStringSync(resource: Resource, ...args: Array<string | number>): string
4549
4550Obtains a string based on the specified resource object and formats the string based on **args**. This API returns the result synchronously.
4551
4552> **NOTE**
4553>
4554> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getStringByNameSync](#getstringbynamesync10) or [getStringSync](#getstringsync10) instead.
4555
4556**Atomic service API**: This API can be used in atomic services since API version 11.
4557
4558**System capability**: SystemCapability.Global.ResourceManager
4559
4560**Model restriction**: This API can be used only in the stage model.
4561
4562**Parameters**
4563
4564| Name     | Type                    | Mandatory  | Description  |
4565| -------- | ---------------------- | ---- | ---- |
4566| resource | [Resource](#resource9) | Yes   | Resource object.|
4567| ...args | Array<string \| number> | No   | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
4568
4569**Return value**
4570
4571| Type    | Description         |
4572| ------ | ---------------------------- |
4573| string | Formatted string corresponding to the specified resource object.|
4574
4575**Error codes**
4576
4577For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4578
4579| ID| Error Message|
4580| -------- | ---------------------------------------- |
4581| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4582| 9001001  | Invalid resource ID.                       |
4583| 9001002  | No matching resource is found based on the resource ID.         |
4584| 9001006  | The resource is referenced cyclically.            |
4585| 9001007  | Failed to format the resource obtained based on the resource ID. |
4586
4587**Example**
4588  ```json
4589  // Resource file path: src/main/resources/base/element/string.json
4590  {
4591    "string": [
4592      {
4593        "name": "test",
4594        "value": "I'm a %1$s, format int: %2$d, format float: %3$f."
4595      }
4596    ]
4597  }
4598  ```
4599  ```ts
4600  import { resourceManager } from '@kit.LocalizationKit';
4601  import { BusinessError } from '@kit.BasicServicesKit';
4602
4603  let resource: resourceManager.Resource = {
4604    bundleName: "com.example.myapplication",
4605    moduleName: "entry",
4606    id: $r('app.string.test').id
4607  };
4608  try {
4609    let testStr = this.context.resourceManager.getStringSync(resource, "format string", 10, 98.78);
4610    console.log(`getStringSync, result: ${testStr}`);
4611    // Print the output result: getStringSync, result: I'm a format string, format int: 10, format float: 98.78.
4612  } catch (error) {
4613    let code = (error as BusinessError).code;
4614    let message = (error as BusinessError).message;
4615    console.error(`getStringSync failed, error code: ${code}, message: ${message}.`);
4616  }
4617  ```
4618### getStringValue<sup>(deprecated)</sup>
4619
4620getStringValue(resource: Resource, callback: _AsyncCallback&lt;string&gt;): void
4621
4622Obtains a string based on the specified resource object. This API uses an asynchronous callback to return the result.
4623
4624> **NOTE**
4625>
4626> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getStringByName](#getstringbyname9) or [getStringValue](#getstringvalue9) instead.
4627
4628**Atomic service API**: This API can be used in atomic services since API version 11.
4629
4630**System capability**: SystemCapability.Global.ResourceManager
4631
4632**Model restriction**: This API can be used only in the stage model.
4633
4634**Parameters**
4635
4636| Name     | Type                         | Mandatory  | Description             |
4637| -------- | --------------------------- | ---- | --------------- |
4638| resource | [Resource](#resource9)      | Yes   | Resource object.           |
4639| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the obtained string.|
4640
4641**Error codes**
4642
4643For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4644
4645| ID| Error Message|
4646| -------- | ---------------------------------------- |
4647| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4648| 9001001  | Invalid resource ID.                       |
4649| 9001002  | No matching resource is found based on the resource ID.         |
4650| 9001006  | The resource is referenced cyclically.            |
4651
4652**Example**
4653  ```json
4654  // Resource file path: src/main/resources/base/element/string.json
4655  {
4656    "string": [
4657      {
4658        "name": "test",
4659        "value": "I'm a test string resource."
4660      }
4661    ]
4662  }
4663  ```
4664  ```ts
4665  import { resourceManager } from '@kit.LocalizationKit';
4666  import { BusinessError } from '@kit.BasicServicesKit';
4667
4668  let resource: resourceManager.Resource = {
4669    bundleName: "com.example.myapplication",
4670    moduleName: "entry",
4671    id: $r('app.string.test').id
4672  };
4673  this.context.resourceManager.getStringValue(resource, (error: BusinessError, value: string) => {
4674    if (error != null) {
4675      console.error(`callback getStringValue failed, error code: ${error.code}, message: ${error.message}.`);
4676    } else {
4677      console.log(`getStringValue, result: ${value}`);
4678      // Print the output result: getStringValue, result: I'm a test string resource.
4679    }
4680  });
4681  ```
4682
4683### getStringValue<sup>(deprecated)</sup>
4684
4685getStringValue(resource: Resource): Promise&lt;string&gt;
4686
4687Obtains a string based on the specified resource object. This API uses a promise to return the result.
4688
4689> **NOTE**
4690>
4691> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getStringByName](#getstringbyname9-1) or [getStringValue](#getstringvalue9-1) instead.
4692
4693**Atomic service API**: This API can be used in atomic services since API version 11.
4694
4695**System capability**: SystemCapability.Global.ResourceManager
4696
4697**Model restriction**: This API can be used only in the stage model.
4698
4699**Parameters**
4700
4701| Name     | Type                    | Mandatory  | Description  |
4702| -------- | ---------------------- | ---- | ---- |
4703| resource | [Resource](#resource9) | Yes   | Resource object.|
4704
4705**Return value**
4706
4707| Type                   | Description              |
4708| --------------------- | ---------------- |
4709| Promise&lt;string&gt; | Promise used to return the obtained string.|
4710
4711**Error codes**
4712
4713For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4714
4715| ID| Error Message|
4716| -------- | ---------------------------------------- |
4717| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4718| 9001001  | Invalid resource ID.                       |
4719| 9001002  | No matching resource is found based on the resource ID.         |
4720| 9001006  | The resource is referenced cyclically.            |
4721
4722**Example**
4723  ```ts
4724  import { resourceManager } from '@kit.LocalizationKit';
4725  import { BusinessError } from '@kit.BasicServicesKit';
4726
4727  let resource: resourceManager.Resource = {
4728    bundleName: "com.example.myapplication",
4729    moduleName: "entry",
4730    id: $r('app.string.test').id
4731  };
4732  this.context.resourceManager.getStringValue(resource, (error: BusinessError, value: string) => {
4733    if (error != null) {
4734      console.error(`callback getStringValue failed, error code: ${error.code}, message: ${error.message}.`);
4735    } else {
4736      console.log(`getStringValue, result: ${value}`);
4737      // Print the output result: getStringValue, result: I'm a test string resource.
4738    }
4739  });
4740  ```
4741
4742### getStringArray<sup>(deprecated)</sup>
4743
4744getStringArray(resId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
4745
4746Obtains a string array based on the specified resource ID. This API uses an asynchronous callback to return the result.
4747
4748> **NOTE**
4749>
4750> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getStringArrayValue](#getstringarrayvalue9).
4751
4752**System capability**: SystemCapability.Global.ResourceManager
4753
4754**Parameters**
4755
4756| Name     | Type                                      | Mandatory  | Description               |
4757| -------- | ---------------------------------------- | ---- | ----------------- |
4758| resId    | number                                   | Yes   | Resource ID.            |
4759| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;Array&lt;string&gt;&gt; | Yes   | Callback used to return the obtained string array.|
4760
4761**Example**
4762  ```ts
4763  resourceManager.getResourceManager((error, mgr) => {
4764      mgr.getStringArray($r('app.strarray.test').id, (error: Error, value: Array<string>) => {
4765          if (error != null) {
4766              console.error("error is " + error);
4767          } else {
4768              let strArray = value;
4769          }
4770      });
4771  });
4772  ```
4773
4774
4775### getStringArray<sup>(deprecated)</sup>
4776
4777getStringArray(resId: number): Promise&lt;Array&lt;string&gt;&gt;
4778
4779Obtains a string array based on the specified resource ID. This API uses a promise to return the result.
4780
4781> **NOTE**
4782>
4783> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getStringArrayValue](#getstringarrayvalue9-1).
4784
4785**System capability**: SystemCapability.Global.ResourceManager
4786
4787**Parameters**
4788
4789| Name  | Type    | Mandatory  | Description   |
4790| ----- | ------ | ---- | ----- |
4791| resId | number | Yes   | Resource ID.|
4792
4793**Return value**
4794
4795| Type                                | Description           |
4796| ---------------------------------- | ------------- |
4797| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the obtained string array.|
4798
4799**Example**
4800  ```ts
4801  import { BusinessError } from '@kit.BasicServicesKit';
4802
4803  resourceManager.getResourceManager((error, mgr) => {
4804       mgr.getStringArray($r('app.strarray.test').id).then((value: Array<string>) => {
4805          let strArray = value;
4806      }).catch((error: BusinessError) => {
4807          console.error("getStringArray promise error is " + error);
4808      });
4809  });
4810  ```
4811
4812### getStringArrayValueSync<sup>(deprecated)</sup>
4813
4814getStringArrayValueSync(resource: Resource): Array&lt;string&gt;
4815
4816Obtains a string array based on the specified resource object. This API returns the result synchronously.
4817
4818> **NOTE**
4819>
4820> This method is supported since API version 10 and is deprecated since API version 20. You are advised to use [getStringArrayByNameSync](#getstringarraybynamesync10) or [getStringArrayValueSync](#getstringarrayvaluesync10) instead.
4821
4822**Atomic service API**: This API can be used in atomic services since API version 11.
4823
4824**System capability**: SystemCapability.Global.ResourceManager
4825
4826**Model restriction**: This API can be used only in the stage model.
4827
4828**Parameters**
4829
4830| Name  | Type    | Mandatory  | Description   |
4831| ----- | ------ | ---- | ----- |
4832| resource | [Resource](#resource9) | Yes   | Resource object.|
4833
4834**Return value**
4835
4836| Type                   | Description         |
4837| --------------------- | ----------- |
4838| Array&lt;string&gt; | String array corresponding to the specified resource object.|
4839
4840**Error codes**
4841
4842For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4843
4844| ID| Error Message|
4845| -------- | ---------------------------------------- |
4846| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4847| 9001001  | Invalid resource ID.                       |
4848| 9001002  | No matching resource is found based on the resource ID.         |
4849| 9001006  | The resource is referenced cyclically.            |
4850
4851**Example**
4852  ```json
4853  // Resource file path: src/main/resources/base/element/strarray.json
4854  {
4855    "strarray": [
4856      {
4857        "name": "test",
4858        "value": [
4859          {
4860            "value": "I'm one of the array's values."
4861          }
4862        ]
4863      }
4864    ]
4865  }
4866  ```
4867  ```ts
4868  import { resourceManager } from '@kit.LocalizationKit';
4869  import { BusinessError } from '@kit.BasicServicesKit';
4870
4871  let resource: resourceManager.Resource = {
4872    bundleName: "com.example.myapplication",
4873    moduleName: "entry",
4874    id: $r('app.strarray.test').id
4875  };
4876  try {
4877    let strArray: Array<string> = this.context.resourceManager.getStringArrayValueSync(resource);
4878    console.log(`getStringArrayValueSync, result: ${strArray[0]}`);
4879    // Print the output result: getStringArrayValueSync, result: I'm one of the array's values.
4880  } catch (error) {
4881    let code = (error as BusinessError).code;
4882    let message = (error as BusinessError).message;
4883    console.error(`getStringArrayValueSync failed, error code: ${code}, message: ${message}.`);
4884  }
4885  ```
4886### getStringArrayValue<sup>(deprecated)</sup>
4887
4888getStringArrayValue(resource: Resource, callback: _AsyncCallback&lt;Array&lt;string&gt;&gt;): void
4889
4890Obtains a string array based on the specified resource object. This API uses an asynchronous callback to return the result.
4891
4892> **NOTE**
4893>
4894> This method is supported since API version 9 and is deprecated since API version 20. You are advised to use [getStringArrayByName](#getstringarraybyname9) or [getStringArrayValue](#getstringarrayvalue9) instead.
4895
4896**Atomic service API**: This API can be used in atomic services since API version 11.
4897
4898**System capability**: SystemCapability.Global.ResourceManager
4899
4900**Model restriction**: This API can be used only in the stage model.
4901
4902**Parameters**
4903
4904| Name     | Type                                      | Mandatory  | Description               |
4905| -------- | ---------------------------------------- | ---- | ----------------- |
4906| resource | [Resource](#resource9)                   | Yes   | Resource object.             |
4907| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Array&lt;string&gt;&gt; | Yes   | Callback used to return the obtained string array.|
4908
4909**Error codes**
4910
4911For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4912
4913| ID| Error Message|
4914| -------- | ---------------------------------------- |
4915| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4916| 9001001  | Invalid resource ID.                       |
4917| 9001002  | No matching resource is found based on the resource ID.         |
4918| 9001006  | The resource is referenced cyclically.            |
4919
4920**Example**
4921  ```json
4922  // Resource file path: src/main/resources/base/element/strarray.json
4923  {
4924    "strarray": [
4925      {
4926        "name": "test",
4927        "value": [
4928          {
4929            "value": "I'm one of the array's values."
4930          }
4931        ]
4932      }
4933    ]
4934  }
4935  ```
4936  ```ts
4937  import { resourceManager } from '@kit.LocalizationKit';
4938  import { BusinessError } from '@kit.BasicServicesKit';
4939
4940  let resource: resourceManager.Resource = {
4941    bundleName: "com.example.myapplication",
4942    moduleName: "entry",
4943    id: $r('app.strarray.test').id
4944  };
4945  this.context.resourceManager.getStringArrayValue(resource, (error: BusinessError, value: Array<string>) => {
4946    if (error != null) {
4947      console.error(`callback getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`);
4948    } else {
4949      console.log(`getStringArrayValue, result: ${value[0]}`);
4950      // Print the output result: getStringArrayValue, result: I'm one of the array's values.
4951    }
4952  });
4953  ```
4954
4955### getStringArrayValue<sup>(deprecated)</sup>
4956
4957getStringArrayValue(resource: Resource): Promise&lt;Array&lt;string&gt;&gt;
4958
4959Obtains a string array based on the specified resource object. This API uses a promise to return the result.
4960
4961> **NOTE**
4962>
4963> This method is supported since API version 9 and is deprecated since API version 20. You are advised to use [getStringArrayByName](#getstringarraybyname9-1) or [getStringArrayValue](#getstringarrayvalue9-1) instead.
4964
4965**Atomic service API**: This API can be used in atomic services since API version 11.
4966
4967**System capability**: SystemCapability.Global.ResourceManager
4968
4969**Model restriction**: This API can be used only in the stage model.
4970
4971**Parameters**
4972
4973| Name     | Type                    | Mandatory  | Description  |
4974| -------- | ---------------------- | ---- | ---- |
4975| resource | [Resource](#resource9) | Yes   | Resource object.|
4976
4977**Return value**
4978
4979| Type                                | Description                |
4980| ---------------------------------- | ------------------ |
4981| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the obtained string array.|
4982
4983**Error codes**
4984
4985For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
4986
4987| ID| Error Message|
4988| -------- | ---------------------------------------- |
4989| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
4990| 9001001  | Invalid resource ID.                       |
4991| 9001002  | No matching resource is found based on the resource ID.         |
4992| 9001006  | The resource is referenced cyclically.            |
4993
4994**Example**
4995  ```json
4996  // Resource file path: src/main/resources/base/element/strarray.json
4997  {
4998    "strarray": [
4999      {
5000        "name": "test",
5001        "value": [
5002          {
5003            "value": "I'm one of the array's values."
5004          }
5005        ]
5006      }
5007    ]
5008  }
5009  ```
5010  ```ts
5011  import { resourceManager } from '@kit.LocalizationKit';
5012  import { BusinessError } from '@kit.BasicServicesKit';
5013
5014  let resource: resourceManager.Resource = {
5015    bundleName: "com.example.myapplication",
5016    moduleName: "entry",
5017    id: $r('app.strarray.test').id
5018  };
5019  this.context.resourceManager.getStringArrayValue(resource)
5020    .then((value: Array<string>) => {
5021      console.log(`getStringArrayValue, result: ${value[0]}`);
5022      // Print the output result: getStringArrayValue, result: I'm one of the array's values.
5023    })
5024    .catch((error: BusinessError) => {
5025      console.error(`promise getStringArrayValue failed, error code: ${error.code}, message: ${error.message}.`);
5026    });
5027  ```
5028
5029### getMedia<sup>(deprecated)</sup>
5030
5031getMedia(resId: number, callback: AsyncCallback&lt;Uint8Array&gt;): void
5032
5033Obtains media file content based on the specified resource ID. This API uses an asynchronous callback to return the result.
5034
5035> **NOTE**
5036>
5037> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9).
5038
5039**System capability**: SystemCapability.Global.ResourceManager
5040
5041**Parameters**
5042
5043| Name     | Type                             | Mandatory  | Description                |
5044| -------- | ------------------------------- | ---- | ------------------ |
5045| resId    | number                          | Yes   | Resource ID.             |
5046| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
5047
5048**Example**
5049  ```ts
5050  resourceManager.getResourceManager((error, mgr) => {
5051      mgr.getMedia($r('app.media.test').id, (error: Error, value: Uint8Array) => {
5052          if (error != null) {
5053              console.error("error is " + error);
5054          } else {
5055              let media = value;
5056          }
5057      });
5058  });
5059  ```
5060
5061### getMedia<sup>(deprecated)</sup>
5062
5063getMedia(resId: number): Promise&lt;Uint8Array&gt;
5064
5065Obtains media file content based on the specified resource ID. This API uses a promise to return the result.
5066
5067> **NOTE**
5068>
5069> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getMediaContent](#getmediacontent9-1).
5070
5071**System capability**: SystemCapability.Global.ResourceManager
5072
5073**Parameters**
5074
5075| Name  | Type    | Mandatory  | Description   |
5076| ----- | ------ | ---- | ----- |
5077| resId | number | Yes   | Resource ID.|
5078
5079**Return value**
5080
5081| Type                       | Description            |
5082| ------------------------- | -------------- |
5083| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
5084
5085**Example**
5086  ```ts
5087  import { BusinessError } from '@kit.BasicServicesKit';
5088
5089  resourceManager.getResourceManager((error, mgr) => {
5090      mgr.getMedia($r('app.media.test').id).then((value: Uint8Array) => {
5091          let media = value;
5092      }).catch((error: BusinessError) => {
5093          console.error("getMedia promise error is " + error);
5094      });
5095  });
5096  ```
5097
5098### getMediaContentSync<sup>(deprecated)</sup>
5099
5100getMediaContentSync(resource: Resource, density?: number): Uint8Array
5101
5102Obtains the media file content for the default or specified screen density based on the specified resource object. This API returns the result synchronously.
5103
5104> **NOTE**
5105>
5106> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getMediaByNameSync](#getmediabynamesync10) or [getMediaContentSync](#getmediacontentsync10) instead.
5107
5108
5109**Atomic service API**: This API can be used in atomic services since API version 11.
5110
5111**System capability**: SystemCapability.Global.ResourceManager
5112
5113**Model restriction**: This API can be used only in the stage model.
5114
5115**Parameters**
5116
5117| Name  | Type    | Mandatory  | Description   |
5118| ----- | ------ | ---- | ----- |
5119| resource | [Resource](#resource9) | Yes   | Resource object.|
5120| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
5121
5122**Return value**
5123
5124| Type                   | Description         |
5125| --------------------- | ----------- |
5126| Uint8Array | Content of the media file corresponding to the specified resource object.|
5127
5128**Error codes**
5129
5130For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5131
5132| ID| Error Message|
5133| -------- | ---------------------------------------- |
5134| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5135| 9001001  | Invalid resource ID.                       |
5136| 9001002  | No matching resource is found based on the resource ID.         |
5137
5138**Example**
5139  ```ts
5140  import { resourceManager } from '@kit.LocalizationKit';
5141  import { BusinessError } from '@kit.BasicServicesKit';
5142
5143  let resource: resourceManager.Resource = {
5144    bundleName: "com.example.myapplication",
5145    moduleName: "entry",
5146    id: $r('app.media.test').id
5147  };
5148  try {
5149    this.context.resourceManager.getMediaContentSync(resource); // Default screen density
5150  } catch (error) {
5151    let code = (error as BusinessError).code;
5152    let message = (error as BusinessError).message;
5153    console.error(`getMediaContentSync failed, error code: ${code}, message: ${message}.`);
5154  }
5155
5156  try {
5157    this.context.resourceManager.getMediaContentSync(resource, 120); // Specified screen density
5158  } catch (error) {
5159    let code = (error as BusinessError).code;
5160    let message = (error as BusinessError).message;
5161    console.error(`getMediaContentSync failed, error code: ${code}, message: ${message}.`);
5162  }
5163  ```
5164
5165### getMediaContent<sup>(deprecated)</sup>
5166
5167getMediaContent(resource: Resource, callback: _AsyncCallback&lt;Uint8Array&gt;): void
5168
5169Obtains media file content based on the specified resource object. This API uses an asynchronous callback to return the result.
5170
5171> **NOTE**
5172>
5173> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getMediaByName](#getmediabyname9) or [getMediaContent](#getmediacontent9) instead.
5174
5175**Atomic service API**: This API can be used in atomic services since API version 11.
5176
5177**System capability**: SystemCapability.Global.ResourceManager
5178
5179**Model restriction**: This API can be used only in the stage model.
5180
5181**Parameters**
5182
5183| Name     | Type                             | Mandatory  | Description                |
5184| -------- | ------------------------------- | ---- | ------------------ |
5185| resource | [Resource](#resource9)          | Yes   | Resource object.              |
5186| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
5187
5188**Error codes**
5189
5190For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5191
5192| ID| Error Message|
5193| -------- | ---------------------------------------- |
5194| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
5195| 9001001  | Invalid resource ID.                       |
5196| 9001002  | No matching resource is found based on the resource ID.         |
5197
5198**Example**
5199  ```ts
5200  import { resourceManager } from '@kit.LocalizationKit';
5201  import { BusinessError } from '@kit.BasicServicesKit';
5202
5203  let resource: resourceManager.Resource = {
5204    bundleName: "com.example.myapplication",
5205    moduleName: "entry",
5206    id: $r('app.media.test').id
5207  };
5208  try {
5209    this.context.resourceManager.getMediaContent(resource, (error: BusinessError, value: Uint8Array) => {
5210      if (error != null) {
5211        console.error("error is " + error);
5212      } else {
5213        let media = value;
5214      }
5215    });
5216  } catch (error) {
5217    let code = (error as BusinessError).code;
5218    let message = (error as BusinessError).message;
5219    console.error(`callback getMediaContent failed, error code: ${code}, message: ${message}.`);
5220  }
5221  ```
5222
5223### getMediaContent<sup>(deprecated)</sup>
5224
5225getMediaContent(resource: Resource, density: number, callback: _AsyncCallback&lt;Uint8Array&gt;): void
5226
5227Obtains media file content for the specified screen density based on the specified resource object. This API uses an asynchronous callback to return the result.
5228
5229> **NOTE**
5230>
5231> This method is supported since API version 10 and is deprecated since API version 20. You are advised to use [getMediaByName](#getmediabyname10) or [getMediaContent](#getmediacontent10) instead.
5232
5233**Atomic service API**: This API can be used in atomic services since API version 11.
5234
5235**System capability**: SystemCapability.Global.ResourceManager
5236
5237**Model restriction**: This API can be used only in the stage model.
5238
5239**Parameters**
5240
5241| Name     | Type                             | Mandatory  | Description                |
5242| -------- | ------------------------------- | ---- | ------------------ |
5243| resource | [Resource](#resource9)          | Yes   | Resource object.              |
5244| [density](#screendensity)  | number        | Yes   | Screen density. The value **0** indicates the default screen density.   |
5245| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;Uint8Array&gt; | Yes   | Callback used to return the media file content.|
5246
5247**Error codes**
5248
5249For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5250
5251| ID| Error Message|
5252| -------- | ---------------------------------------- |
5253| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5254| 9001001  | Invalid resource ID.                       |
5255| 9001002  | No matching resource is found based on the resource ID.         |
5256
5257**Example**
5258  ```ts
5259  import { resourceManager } from '@kit.LocalizationKit';
5260  import { BusinessError } from '@kit.BasicServicesKit';
5261
5262  let resource: resourceManager.Resource = {
5263    bundleName: "com.example.myapplication",
5264    moduleName: "entry",
5265    id: $r('app.media.test').id
5266  };
5267  try {
5268    this.context.resourceManager.getMediaContent(resource, 120, (error: BusinessError, value: Uint8Array) => {
5269      if (error != null) {
5270        console.error(`callback getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
5271      } else {
5272        let media = value;
5273      }
5274    });
5275  } catch (error) {
5276    let code = (error as BusinessError).code;
5277    let message = (error as BusinessError).message;
5278    console.error(`callback getMediaContent failed, error code: ${code}, message: ${message}.`);
5279  }
5280  ```
5281
5282### getMediaContent<sup>(deprecated)</sup>
5283
5284getMediaContent(resource: Resource): Promise&lt;Uint8Array&gt;
5285
5286Obtains media file content based on the specified resource object. This API uses a promise to return the result.
5287
5288> **NOTE**
5289>
5290> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getMediaByName](#getmediabyname9-1) or [getMediaContent](#getmediacontent9-1) instead.
5291
5292**Atomic service API**: This API can be used in atomic services since API version 11.
5293
5294**System capability**: SystemCapability.Global.ResourceManager
5295
5296**Model restriction**: This API can be used only in the stage model.
5297
5298**Parameters**
5299
5300| Name     | Type                    | Mandatory  | Description  |
5301| -------- | ---------------------- | ---- | ---- |
5302| resource | [Resource](#resource9) | Yes   | Resource object.|
5303
5304**Return value**
5305
5306| Type                       | Description                 |
5307| ------------------------- | ------------------- |
5308| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
5309
5310**Error codes**
5311
5312For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5313
5314| ID| Error Message|
5315| -------- | ---------------------------------------- |
5316| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
5317| 9001001  | Invalid resource ID.                       |
5318| 9001002  | No matching resource is found based on the resource ID.         |
5319
5320**Example**
5321  ```ts
5322  import { resourceManager } from '@kit.LocalizationKit';
5323  import { BusinessError } from '@kit.BasicServicesKit';
5324
5325  let resource: resourceManager.Resource = {
5326    bundleName: "com.example.myapplication",
5327    moduleName: "entry",
5328    id: $r('app.media.test').id
5329  };
5330  try {
5331    this.context.resourceManager.getMediaContent(resource).then((value: Uint8Array) => {
5332      let media = value;
5333    }).catch((error: BusinessError) => {
5334      console.error("getMediaContent promise error is " + error);
5335    });
5336  } catch (error) {
5337    let code = (error as BusinessError).code;
5338    let message = (error as BusinessError).message;
5339    console.error(`promise getMediaContent failed, error code: ${code}, message: ${message}.`);
5340  }
5341  ```
5342
5343### getMediaContent<sup>(deprecated)</sup>
5344
5345getMediaContent(resource: Resource, density: number): Promise&lt;Uint8Array&gt;
5346
5347Obtains media file content for the specified screen density based on the specified resource object. This API uses a promise to return the result.
5348
5349> **NOTE**
5350>
5351> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getMediaByName](#getmediabyname10-1) or [getMediaContent](#getmediacontent10-1) instead.
5352
5353**Atomic service API**: This API can be used in atomic services since API version 11.
5354
5355**System capability**: SystemCapability.Global.ResourceManager
5356
5357**Model restriction**: This API can be used only in the stage model.
5358
5359**Parameters**
5360
5361| Name     | Type                    | Mandatory  | Description  |
5362| -------- | ---------------------- | ---- | ---- |
5363| resource | [Resource](#resource9) | Yes   | Resource object.|
5364| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
5365
5366**Return value**
5367
5368| Type                       | Description                 |
5369| ------------------------- | ------------------- |
5370| Promise&lt;Uint8Array&gt; | Promise used to return the media file content.|
5371
5372**Error codes**
5373
5374For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5375
5376| ID| Error Message|
5377| -------- | ---------------------------------------- |
5378| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5379| 9001001  | Invalid resource ID.                       |
5380| 9001002  | No matching resource is found based on the resource ID.         |
5381
5382**Example**
5383  ```ts
5384  import { resourceManager } from '@kit.LocalizationKit';
5385  import { BusinessError } from '@kit.BasicServicesKit';
5386
5387  let resource: resourceManager.Resource = {
5388    bundleName: "com.example.myapplication",
5389    moduleName: "entry",
5390    id: $r('app.media.test').id
5391  };
5392  try {
5393    this.context.resourceManager.getMediaContent(resource, 120).then((value: Uint8Array) => {
5394      let media = value;
5395    }).catch((error: BusinessError) => {
5396      console.error(`promise getMediaContent failed, error code: ${error.code}, message: ${error.message}.`);
5397    });
5398  } catch (error) {
5399    let code = (error as BusinessError).code;
5400    let message = (error as BusinessError).message;
5401    console.error(`promise getMediaContent failed, error code: ${code}, message: ${message}.`);
5402  }
5403  ```
5404
5405### getMediaBase64<sup>(deprecated)</sup>
5406
5407getMediaBase64(resId: number, callback: AsyncCallback&lt;string&gt;): void
5408
5409Obtains an image's Base64 code based on the specified resource ID. This API uses an asynchronous callback to return the result.
5410
5411> **NOTE**
5412>
5413> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getMediaContentBase64](#getmediacontentbase649).
5414
5415**System capability**: SystemCapability.Global.ResourceManager
5416
5417**Parameters**
5418
5419| Name     | Type                         | Mandatory  | Description                      |
5420| -------- | --------------------------- | ---- | ------------------------ |
5421| resId    | number                      | Yes   | Resource ID.                   |
5422| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
5423
5424**Example**
5425  ```ts
5426  resourceManager.getResourceManager((error, mgr) => {
5427      mgr.getMediaBase64($r('app.media.test').id, ((error: Error, value: string) => {
5428          if (error != null) {
5429              console.error("error is " + error);
5430          } else {
5431              let media = value;
5432          }
5433      });
5434  });
5435  ```
5436
5437
5438### getMediaBase64<sup>(deprecated)</sup>
5439
5440getMediaBase64(resId: number): Promise&lt;string&gt;
5441
5442Obtains an image's Base64 code based on the specified resource ID. This API uses a promise to return the result.
5443
5444> **NOTE**
5445>
5446> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getMediaContentBase64](#getmediacontentbase649-1).
5447
5448**System capability**: SystemCapability.Global.ResourceManager
5449
5450**Parameters**
5451
5452| Name  | Type    | Mandatory  | Description   |
5453| ----- | ------ | ---- | ----- |
5454| resId | number | Yes   | Resource ID.|
5455
5456**Return value**
5457
5458| Type                   | Description                  |
5459| --------------------- | -------------------- |
5460| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
5461
5462**Example**
5463  ```ts
5464  import { BusinessError } from '@kit.BasicServicesKit';
5465
5466  resourceManager.getResourceManager((error, mgr) => {
5467      mgr.getMediaBase64($r('app.media.test').id).then((value: string) => {
5468          let media = value;
5469      }).catch((error: BusinessError) => {
5470          console.error("getMediaBase64 promise error is " + error);
5471      });
5472  });
5473  ```
5474### getMediaContentBase64Sync<sup>(deprecated)</sup>
5475
5476getMediaContentBase64Sync(resource: Resource, density?: number): string
5477
5478Obtains an image's Base64 code for the default or specified screen density based on the specified resource object. This API returns the result synchronously.
5479
5480> **NOTE**
5481>
5482> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getMediaBase64ByNameSync](#getmediabase64bynamesync10) or [getMediaContentBase64Sync](#getmediacontentbase64sync10) instead.
5483
5484**Atomic service API**: This API can be used in atomic services since API version 11.
5485
5486**System capability**: SystemCapability.Global.ResourceManager
5487
5488**Model restriction**: This API can be used only in the stage model.
5489
5490**Parameters**
5491
5492| Name  | Type    | Mandatory  | Description   |
5493| ----- | ------ | ---- | ----- |
5494| resource | [Resource](#resource9) | Yes   | Resource object.|
5495| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
5496
5497**Return value**
5498
5499| Type                   | Description         |
5500| --------------------- | ----------- |
5501| string | Base64 code of the image corresponding to the specified resource object.|
5502
5503**Error codes**
5504
5505For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5506
5507| ID| Error Message|
5508| -------- | ---------------------------------------- |
5509| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5510| 9001001  | Invalid resource ID.                       |
5511| 9001002  | No matching resource is found based on the resource ID.         |
5512
5513**Example**
5514  ```ts
5515  import { resourceManager } from '@kit.LocalizationKit';
5516  import { BusinessError } from '@kit.BasicServicesKit';
5517
5518  let resource: resourceManager.Resource = {
5519    bundleName: "com.example.myapplication",
5520    moduleName: "entry",
5521    id: $r('app.media.test').id
5522  };
5523  try {
5524    this.context.resourceManager.getMediaContentBase64Sync(resource); // Default screen density
5525  } catch (error) {
5526    let code = (error as BusinessError).code;
5527    let message = (error as BusinessError).message;
5528    console.error(`getMediaContentBase64Sync failed, error code: ${code}, message: ${message}.`);
5529  }
5530
5531  try {
5532    this.context.resourceManager.getMediaContentBase64Sync(resource, 120); // Specified screen density
5533  } catch (error) {
5534    let code = (error as BusinessError).code;
5535    let message = (error as BusinessError).message;
5536    console.error(`getMediaContentBase64Sync failed, error code: ${code}, message: ${message}.`);
5537  }
5538  ```
5539### getMediaContentBase64<sup>(deprecated)</sup>
5540
5541getMediaContentBase64(resource: Resource, callback: _AsyncCallback&lt;string&gt;): void
5542
5543Obtains an image's Base64 code based on the specified resource object. This API uses an asynchronous callback to return the result.
5544
5545> **NOTE**
5546>
5547> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getMediaBase64ByName](#getmediabase64byname9) or [getMediaContentBase64](#getmediacontentbase649) instead.
5548
5549**Atomic service API**: This API can be used in atomic services since API version 11.
5550
5551**System capability**: SystemCapability.Global.ResourceManager
5552
5553**Model restriction**: This API can be used only in the stage model.
5554
5555**Parameters**
5556
5557| Name     | Type                         | Mandatory  | Description                      |
5558| -------- | --------------------------- | ---- | ------------------------ |
5559| resource | [Resource](#resource9)      | Yes   | Resource object.                    |
5560| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
5561
5562**Error codes**
5563
5564For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5565
5566| ID| Error Message|
5567| -------- | ---------------------------------------- |
5568| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
5569| 9001001  | Invalid resource ID.                       |
5570| 9001002  | No matching resource is found based on the resource ID.         |
5571
5572**Example**
5573  ```ts
5574  import { resourceManager } from '@kit.LocalizationKit';
5575  import { BusinessError } from '@kit.BasicServicesKit';
5576
5577  let resource: resourceManager.Resource = {
5578    bundleName: "com.example.myapplication",
5579    moduleName: "entry",
5580    id: $r('app.media.test').id
5581  };
5582  try {
5583    this.context.resourceManager.getMediaContentBase64(resource, (error: BusinessError, value: string) => {
5584      if (error != null) {
5585        console.error("error is " + error);
5586      } else {
5587        let media = value;
5588      }
5589    });
5590  } catch (error) {
5591    let code = (error as BusinessError).code;
5592    let message = (error as BusinessError).message;
5593    console.error(`callback getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
5594  }
5595  ```
5596
5597### getMediaContentBase64<sup>(deprecated)</sup>
5598
5599getMediaContentBase64(resource: Resource, density: number, callback: _AsyncCallback&lt;string&gt;): void
5600
5601Obtains an image's Base64 code for the specified screen density based on the specified resource object. This API uses an asynchronous callback to return the result.
5602
5603> **NOTE**
5604>
5605> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getMediaBase64ByName](#getmediabase64byname10) or [getMediaContentBase64](#getmediacontentbase6410) instead.
5606
5607**Atomic service API**: This API can be used in atomic services since API version 11.
5608
5609**System capability**: SystemCapability.Global.ResourceManager
5610
5611**Model restriction**: This API can be used only in the stage model.
5612
5613**Parameters**
5614
5615| Name     | Type                         | Mandatory  | Description                      |
5616| -------- | --------------------------- | ---- | ------------------------ |
5617| resource | [Resource](#resource9)      | Yes   | Resource object.                    |
5618| [density](#screendensity)  | number        | Yes   | Screen density. The value **0** indicates the default screen density.   |
5619| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes   | Callback used to return the Base64 code of the image.|
5620
5621**Error codes**
5622
5623For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5624
5625| ID| Error Message|
5626| -------- | ---------------------------------------- |
5627| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5628| 9001001  | Invalid resource ID.                       |
5629| 9001002  | No matching resource is found based on the resource ID.         |
5630
5631**Example**
5632  ```ts
5633  import { resourceManager } from '@kit.LocalizationKit';
5634  import { BusinessError } from '@kit.BasicServicesKit';
5635
5636  let resource: resourceManager.Resource = {
5637    bundleName: "com.example.myapplication",
5638    moduleName: "entry",
5639    id: $r('app.media.test').id
5640  };
5641  try {
5642    this.context.resourceManager.getMediaContentBase64(resource, 120, (error: BusinessError, value: string) => {
5643      if (error != null) {
5644        console.error(`callback getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
5645      } else {
5646        let media = value;
5647      }
5648    });
5649  } catch (error) {
5650    let code = (error as BusinessError).code;
5651    let message = (error as BusinessError).message;
5652    console.error(`callback getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
5653  }
5654  ```
5655
5656### getMediaContentBase64<sup>(deprecated)</sup>
5657
5658getMediaContentBase64(resource: Resource): Promise&lt;string&gt;
5659
5660Obtains an image's Base64 code based on the specified resource object. This API uses a promise to return the result.
5661
5662> **NOTE**
5663>
5664> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getMediaBase64ByName](#getmediabase64byname9-1) or [getMediaContentBase64](#getmediacontentbase649-1).
5665
5666**Atomic service API**: This API can be used in atomic services since API version 11.
5667
5668**System capability**: SystemCapability.Global.ResourceManager
5669
5670**Model restriction**: This API can be used only in the stage model.
5671
5672**Parameters**
5673
5674| Name     | Type                    | Mandatory  | Description  |
5675| -------- | ---------------------- | ---- | ---- |
5676| resource | [Resource](#resource9) | Yes   | Resource object.|
5677
5678**Return value**
5679
5680| Type                   | Description                       |
5681| --------------------- | ------------------------- |
5682| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
5683
5684**Error codes**
5685
5686For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5687
5688| ID| Error Message|
5689| -------- | ---------------------------------------- |
5690| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
5691| 9001001  | Invalid resource ID.                       |
5692| 9001002  | No matching resource is found based on the resource ID.         |
5693
5694**Example**
5695  ```ts
5696  import { resourceManager } from '@kit.LocalizationKit';
5697  import { BusinessError } from '@kit.BasicServicesKit';
5698
5699  let resource: resourceManager.Resource = {
5700    bundleName: "com.example.myapplication",
5701    moduleName: "entry",
5702    id: $r('app.media.test').id
5703  };
5704  try {
5705    this.context.resourceManager.getMediaContentBase64(resource).then((value: string) => {
5706      let media = value;
5707    }).catch((error: BusinessError) => {
5708      console.error("getMediaContentBase64 promise error is " + error);
5709    });
5710  } catch (error) {
5711    let code = (error as BusinessError).code;
5712    let message = (error as BusinessError).message;
5713    console.error(`promise getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
5714  }
5715  ```
5716
5717### getMediaContentBase64<sup>(deprecated)</sup>
5718
5719getMediaContentBase64(resource: Resource, density: number): Promise&lt;string&gt;
5720
5721Obtains an image's Base64 code for the specified screen density based on the specified resource object. This API uses a promise to return the result.
5722
5723> **NOTE**
5724>
5725> Supports versions from API version 10 and is deprecated in API version 20. You are advised to use [getMediaBase64ByName](#getmediabase64byname10-1) or [getMediaContentBase64](#getmediacontentbase6410-1) instead.
5726
5727**Atomic service API**: This API can be used in atomic services since API version 11.
5728
5729**System capability**: SystemCapability.Global.ResourceManager
5730
5731**Model restriction**: This API can be used only in the stage model.
5732
5733**Parameters**
5734
5735| Name     | Type                    | Mandatory  | Description  |
5736| -------- | ---------------------- | ---- | ---- |
5737| resource | [Resource](#resource9) | Yes   | Resource object.|
5738| [density](#screendensity)  | number                          | Yes   | Screen density. The value **0** indicates the default screen density.   |
5739
5740**Return value**
5741
5742| Type                   | Description                       |
5743| --------------------- | ------------------------- |
5744| Promise&lt;string&gt; | Promise used to return the Base64 code of the image.|
5745
5746**Error codes**
5747
5748For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5749
5750| ID| Error Message|
5751| -------- | ---------------------------------------- |
5752| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5753| 9001001  | Invalid resource ID.                       |
5754| 9001002  | No matching resource is found based on the resource ID.         |
5755
5756**Example**
5757  ```ts
5758  import { resourceManager } from '@kit.LocalizationKit';
5759  import { BusinessError } from '@kit.BasicServicesKit';
5760
5761  let resource: resourceManager.Resource = {
5762    bundleName: "com.example.myapplication",
5763    moduleName: "entry",
5764    id: $r('app.media.test').id
5765  };
5766  try {
5767    this.context.resourceManager.getMediaContentBase64(resource, 120).then((value: string) => {
5768      let media = value;
5769    }).catch((error: BusinessError) => {
5770      console.error(`promise getMediaContentBase64 failed, error code: ${error.code}, message: ${error.message}.`);
5771    });
5772  } catch (error) {
5773    let code = (error as BusinessError).code;
5774    let message = (error as BusinessError).message;
5775    console.error(`promise getMediaContentBase64 failed, error code: ${code}, message: ${message}.`);
5776  }
5777  ```
5778### getDrawableDescriptor<sup>(deprecated)</sup>
5779
5780getDrawableDescriptor(resource: Resource, density?: number, type?: number): DrawableDescriptor
5781
5782Obtains a **DrawableDescriptor** object for icon display based on the specified resource object. This API returns the result synchronously.
5783
5784> **NOTE**
5785>
5786> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getDrawableDescriptorByName](#getdrawabledescriptorbyname10) or [getDrawableDescriptor] (#getdrawabledescriptor10) instead.
5787
5788**Atomic service API**: This API can be used in atomic services since API version 11.
5789
5790**System capability**: SystemCapability.Global.ResourceManager
5791
5792**Model restriction**: This API can be used only in the stage model.
5793
5794**Parameters**
5795
5796| Name     | Type                    | Mandatory  | Description  |
5797| -------- | ---------------------- | ---- | ---- |
5798| resource | [Resource](#resource9) | Yes   | Resource object.|
5799| [density](#screendensity) | number | No   | Screen density. The default value or value **0** indicates the default screen density.|
5800| type<sup>11+</sup> | number | No   | - **1**: Layered icon resource of the application in the theme resource package.<br> - **0** or default value: Icon resource of the application.|
5801
5802**Return value**
5803
5804| Type     | Description               |
5805| ------- | ----------------- |
5806| [DrawableDescriptor](../apis-arkui/js-apis-arkui-drawableDescriptor.md#drawabledescriptor) | **DrawableDescriptor** object corresponding to the specified resource ID.|
5807
5808**Error codes**
5809
5810For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
5811
5812| ID| Error Message|
5813| -------- | ---------------------------------------- |
5814| 401 | If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 2.Parameter verification failed.               |
5815| 9001001  | Invalid resource ID.                       |
5816| 9001002  | No matching resource is found based on the resource ID.         |
5817
5818**Example**
5819  ```ts
5820  import { resourceManager } from '@kit.LocalizationKit';
5821  import { BusinessError } from '@kit.BasicServicesKit';
5822  import { DrawableDescriptor } from '@kit.ArkUI';
5823
5824  let resource: resourceManager.Resource = {
5825    bundleName: "com.example.myapplication",
5826    moduleName: "entry",
5827    id: $r('app.media.icon').id
5828  };
5829  try {
5830    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptor(resource);
5831  } catch (error) {
5832    let code = (error as BusinessError).code;
5833    let message = (error as BusinessError).message;
5834    console.error(`getDrawableDescriptor failed, error code: ${code}, message: ${message}.`);
5835  }
5836  try {
5837    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptor(resource, 120);
5838  } catch (error) {
5839    let code = (error as BusinessError).code;
5840    let message = (error as BusinessError).message;
5841    console.error(`getDrawableDescriptor failed, error code: ${code}, message: ${message}.`);
5842  }
5843  try {
5844    let drawableDescriptor:DrawableDescriptor = this.context.resourceManager.getDrawableDescriptor(resource, 0, 1);
5845  } catch (error) {
5846    let code = (error as BusinessError).code;
5847    let message = (error as BusinessError).message;
5848    console.error(`getDrawableDescriptor failed, error code: ${code}, message: ${message}.`);
5849  }
5850  ```
5851
5852### getIntPluralStringValueSync<sup>(deprecated)</sup>
5853
5854getIntPluralStringValueSync(resource: Resource, num: number, ...args: Array<string | number>): string
5855
5856Obtains a [singular/plural](../../internationalization/l10n-singular-plural.md) string based on the specified resource object and formats the string based on the **args** parameter. This API returns the result synchronously.
5857
5858> **NOTE**
5859>
5860> - This API is supported since API version 18 and is deprecated since API version 20. You are advised to use [getIntPluralStringByNameSync](#getintpluralstringbynamesync18) or [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
5861>
5862> - Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
5863
5864**Atomic service API**: This API can be used in atomic services since API version 18.
5865
5866**System capability**: SystemCapability.Global.ResourceManager
5867
5868**Model restriction**: This API can be used only in the stage model.
5869
5870**Parameters**
5871
5872| Name  | Type                   | Mandatory| Description                                                        |
5873| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
5874| resource | [Resource](#resource9)  | Yes  | Resource object.                                                  |
5875| num      | number                  | Yes  | Integer number used to obtain the corresponding string representation based on the current language's [plural rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
5876| ...args  | Array<string \| number> | No  | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
5877
5878**Return value**
5879
5880| Type  | Description                                |
5881| ------ | ------------------------------------ |
5882| string | Formatted string corresponding to the specified resource object.|
5883
5884**Error codes**
5885
5886For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
5887
5888| ID| Error Message                                                    |
5889| -------- | ------------------------------------------------------------ |
5890| 9001001  | Invalid resource ID.                                         |
5891| 9001002  | No matching resource is found based on the resource ID.      |
5892| 9001006  | The resource is referenced cyclically.                       |
5893| 9001007  | Failed to format the resource obtained based on the resource ID. |
5894
5895**Example**
5896  ```json
5897  // Resource file path: src/main/resources/base/element/plural.json
5898  {
5899    "plural": [
5900      {
5901        "name": "format_test",
5902        "value": [
5903          {
5904            "quantity": "one",
5905            "value": "There is %d apple in the %s, the total amount is %f kg."
5906          },
5907          {
5908            "quantity": "other",
5909            "value": "There are %d apples in the %s, the total amount is %f kg."
5910          }
5911        ]
5912      }
5913    ]
5914  }
5915  ```
5916  ```ts
5917  import { resourceManager } from '@kit.LocalizationKit';
5918  import { BusinessError } from '@kit.BasicServicesKit';
5919
5920  let resource: resourceManager.Resource = {
5921    bundleName: "com.example.myapplication",
5922    moduleName: "entry",
5923    id: $r('app.plural.format_test').id
5924  };
5925
5926  try {
5927    // If num is 1, the single/plural type is one in the English environment.
5928    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
5929    let pluralStr = this.context.resourceManager.getIntPluralStringValueSync(resource, 1, 1, "basket", 0.3);
5930    console.log(`getIntPluralStringValueSync, result: ${pluralStr}`);
5931    // Print the output result: getIntPluralStringValueSync, result: There is 1 apple in the basket, the total amount is 0.3 kg.
5932  } catch (error) {
5933    let code = (error as BusinessError).code;
5934    let message = (error as BusinessError).message;
5935    console.error(`getIntPluralStringValueSync failed, error code: ${code}, message: ${message}.`);
5936  }
5937  ```
5938
5939### getDoublePluralStringValueSync<sup>(deprecated)</sup>
5940
5941getDoublePluralStringValueSync(resource: Resource, num: number, ...args: Array<string | number>): string
5942
5943Obtains a [singular/plural](../../internationalization/l10n-singular-plural.md) string based on the specified resource object and formats the string based on the **args** parameter. This API returns the result synchronously.
5944
5945> **NOTE**
5946>
5947> - This API is supported since API version 18 and is deprecated since API version 20. You are advised to use [getDoublePluralStringByNameSync](#getdoublepluralstringbynamesync18) or [getDoublePluralStringValueSync](#getdoublepluralstringvaluesync18) instead.
5948>
5949> - Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
5950
5951**Atomic service API**: This API can be used in atomic services since API version 18.
5952
5953**System capability**: SystemCapability.Global.ResourceManager
5954
5955**Model restriction**: This API can be used only in the stage model.
5956
5957**Parameters**
5958
5959| Name  | Type                   | Mandatory| Description                                                        |
5960| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
5961| resource | [Resource](#resource9)  | Yes  | Resource object.                                                  |
5962| num      | number                  | Yes  | Quantity value (a floating point number), used to obtain the corresponding string representation based on the current language's [plural rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
5963| ...args  | Array<string \| number> | No  | Arguments for formatting strings.<br>Supported value types include `%d`, `%f`, `%s`, `%%`, `%number$d`, `%number$f`, and `%number$s`.<br>Note: `%%` is converted to `%`. **number** in `%number$d` indicates the sequence number of the parameter in **args**.<br>For example, `%%d` is converted to `%d` after formatting, and `%1$d` indicates that the first parameter is used.|
5964
5965**Return value**
5966
5967| Type  | Description                                    |
5968| ------ | ---------------------------------------- |
5969| string | Formatted string corresponding to the specified resource object.|
5970
5971**Error codes**
5972
5973For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
5974
5975| ID| Error Message                                                    |
5976| -------- | ------------------------------------------------------------ |
5977| 9001001  | Invalid resource ID.                                         |
5978| 9001002  | No matching resource is found based on the resource ID.      |
5979| 9001006  | The resource is referenced cyclically.                       |
5980| 9001007  | Failed to format the resource obtained based on the resource ID. |
5981
5982**Example**
5983  ```json
5984  // Resource file path: src/main/resources/base/element/plural.json
5985  {
5986    "plural": [
5987      {
5988        "name": "format_test",
5989        "value": [
5990          {
5991            "quantity": "one",
5992            "value": "There is %d apple in the %s, the total amount is %f kg."
5993          },
5994          {
5995            "quantity": "other",
5996            "value": "There are %d apples in the %s, the total amount is %f kg."
5997          }
5998        ]
5999      }
6000    ]
6001  }
6002  ```
6003  ```ts
6004  import { resourceManager } from '@kit.LocalizationKit';
6005  import { BusinessError } from '@kit.BasicServicesKit';
6006
6007  let resource: resourceManager.Resource = {
6008    bundleName: "com.example.myapplication",
6009    moduleName: "entry",
6010    id: $r('app.plural.format_test').id
6011  };
6012
6013  try {
6014    // If num is 2.1, the single/plural type is other in the English environment.
6015    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is other is obtained.
6016    let pluralStr = this.context.resourceManager.getDoublePluralStringValueSync(resource, 2.1, 2, "basket", 0.6);
6017    console.log(`getDoublePluralStringValueSync, result: ${pluralStr}`);
6018    // Print the output result: getIntPluralStringValueSync, result: There are 2 apples in the basket, the total amount is 0.6 kg.
6019  } catch (error) {
6020    let code = (error as BusinessError).code;
6021    let message = (error as BusinessError).message;
6022    console.error(`getDoublePluralStringValueSync failed, error code: ${code}, message: ${message}.`);
6023  }
6024  ```
6025
6026### getPluralStringValueSync<sup>(deprecated)</sup>
6027
6028getPluralStringValueSync(resId: number, num: number): string
6029
6030Obtains singular/plural strings based on the specified resource ID and quantity. This API returns the result synchronously.
6031
6032> **NOTE**
6033>
6034> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6035>
6036> This API is supported since API version 10 and is deprecated since API version 18. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6037
6038**Atomic service API**: This API can be used in atomic services since API version 11.
6039
6040**System capability**: SystemCapability.Global.ResourceManager
6041
6042**Parameters**
6043
6044| Name| Type  | Mandatory| Description                                                        |
6045| ------ | ------ | ---- | ------------------------------------------------------------ |
6046| resId  | number | Yes  | Resource ID.                                                  |
6047| num    | number | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6048
6049**Return value**
6050
6051| Type  | Description                                            |
6052| ------ | ------------------------------------------------ |
6053| string | Singular/plural string corresponding to the specified quantity and resource ID.|
6054
6055**Error codes**
6056
6057For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6058
6059| ID| Error Message                                                    |
6060| -------- | ------------------------------------------------------------ |
6061| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6062| 9001001  | Invalid resource ID.                                         |
6063| 9001002  | No matching resource is found based on the resource ID.      |
6064| 9001006  | The resource is referenced cyclically.                       |
6065
6066**Example**
6067  ```json
6068  // Resource file path: src/main/resources/base/element/plural.json
6069  {
6070    "plural": [
6071      {
6072        "name": "test",
6073        "value": [
6074          {
6075            "quantity": "one",
6076            "value": "%d apple"
6077          },
6078          {
6079            "quantity": "other",
6080            "value": "%d apples"
6081          }
6082        ]
6083      }
6084    ]
6085  }
6086  ```
6087  ```ts
6088  import { BusinessError } from '@kit.BasicServicesKit';
6089
6090  try {
6091    // If num is 1, the single/plural type is one in the English environment.
6092    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6093    let pluralValue = this.context.resourceManager.getPluralStringValueSync($r('app.plural.test').id, 1);
6094    console.log(`getPluralStringValueSync, result: ${pluralValue}`);
6095    // Print the output result: getPluralStringValueSync, result: 1 apple
6096  } catch (error) {
6097    let code = (error as BusinessError).code;
6098    let message = (error as BusinessError).message;
6099    console.error(`getPluralStringValueSync failed, error code: ${code}, message: ${message}.`);
6100  }
6101  ```
6102
6103### getPluralStringValueSync<sup>(deprecated)</sup>
6104
6105getPluralStringValueSync(resource: Resource, num: number): string
6106
6107Obtains singular/plural strings based on the specified quantity and resource object. This API returns the result synchronously.
6108
6109> **NOTE**
6110>
6111> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6112>
6113> This API is supported since API version 10 and is deprecated since API version 18. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6114
6115**Atomic service API**: This API can be used in atomic services since API version 11.
6116
6117**System capability**: SystemCapability.Global.ResourceManager
6118
6119**Model restriction**: This API can be used only in the stage model.
6120
6121**Parameters**
6122
6123| Name  | Type                  | Mandatory| Description                                                        |
6124| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
6125| resource | [Resource](#resource9) | Yes  | Resource object.                                                  |
6126| num      | number                 | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6127
6128**Return value**
6129
6130| Type  | Description                                                |
6131| ------ | ---------------------------------------------------- |
6132| string | Singular/plural string corresponding to the specified quantity and resource object.|
6133
6134**Error codes**
6135
6136For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6137
6138| ID| Error Message                                                    |
6139| -------- | ------------------------------------------------------------ |
6140| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6141| 9001001  | Invalid resource ID.                                         |
6142| 9001002  | No matching resource is found based on the resource ID.      |
6143| 9001006  | The resource is referenced cyclically.                       |
6144
6145**Example**
6146  ```json
6147  // Resource file path: src/main/resources/base/element/plural.json
6148  {
6149    "plural": [
6150      {
6151        "name": "test",
6152        "value": [
6153          {
6154            "quantity": "one",
6155            "value": "%d apple"
6156          },
6157          {
6158            "quantity": "other",
6159            "value": "%d apples"
6160          }
6161        ]
6162      }
6163    ]
6164  }
6165  ```
6166  ```ts
6167  import { resourceManager } from '@kit.LocalizationKit';
6168  import { BusinessError } from '@kit.BasicServicesKit';
6169
6170  let resource: resourceManager.Resource = {
6171    bundleName: "com.example.myapplication",
6172    moduleName: "entry",
6173    id: $r('app.plural.test').id
6174  };
6175  try {
6176    // If num is 1, the single/plural type is one in the English environment.
6177    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6178    let pluralValue = this.context.resourceManager.getPluralStringValueSync(resource, 1);
6179    console.log(`getPluralStringValueSync, result: ${pluralValue}`);
6180    // Print the output result: getPluralStringValueSync, result: 1 apple
6181  } catch (error) {
6182    let code = (error as BusinessError).code;
6183    let message = (error as BusinessError).message;
6184    console.error(`getPluralStringValueSync failed, error code: ${code}, message: ${message}.`);
6185  }
6186  ```
6187
6188### getPluralStringByNameSync<sup>(deprecated)</sup>
6189
6190getPluralStringByNameSync(resName: string, num: number): string
6191
6192Obtains singular/plural strings based on the specified quantity and resource name. This API returns the result synchronously.
6193
6194> **NOTE**
6195>
6196> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6197>
6198> This API is supported since API version 10 and is deprecated since API version 18. You are advised to use [getIntPluralStringByNameSync](#getintpluralstringbynamesync18) instead.
6199
6200**Atomic service API**: This API can be used in atomic services since API version 11.
6201
6202**System capability**: SystemCapability.Global.ResourceManager
6203
6204**Parameters**
6205
6206| Name | Type  | Mandatory| Description                                                        |
6207| ------- | ------ | ---- | ------------------------------------------------------------ |
6208| resName | string | Yes  | Resource name.                                                  |
6209| num     | number | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6210
6211**Return value**
6212
6213| Type  | Description                                            |
6214| ------ | ------------------------------------------------ |
6215| string | Singular/plural string corresponding to the specified quantity and resource name.|
6216
6217**Error codes**
6218
6219For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6220
6221| ID| Error Message                                                    |
6222| -------- | ------------------------------------------------------------ |
6223| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6224| 9001003  | Invalid resource name.                                       |
6225| 9001004  | No matching resource is found based on the resource name.    |
6226| 9001006  | The resource is referenced cyclically.                       |
6227
6228**Example**
6229  ```json
6230  // Resource file path: src/main/resources/base/element/plural.json
6231  {
6232    "plural": [
6233      {
6234        "name": "test",
6235        "value": [
6236          {
6237            "quantity": "one",
6238            "value": "%d apple"
6239          },
6240          {
6241            "quantity": "other",
6242            "value": "%d apples"
6243          }
6244        ]
6245      }
6246    ]
6247  }
6248  ```
6249  ```ts
6250  import { BusinessError } from '@kit.BasicServicesKit';
6251
6252  try {
6253    // If num is 1, the single/plural type is one in the English environment.
6254    // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6255    let pluralValue = this.context.resourceManager.getPluralStringByNameSync("test", 1);
6256    console.log(`getPluralStringByNameSync, result: ${pluralValue}`);
6257    // Print the output result: getPluralStringByNameSync, result: 1 apple
6258  } catch (error) {
6259    let code = (error as BusinessError).code;
6260    let message = (error as BusinessError).message;
6261    console.error(`getPluralStringByNameSync failed, error code: ${code}, message: ${message}.`);
6262  }
6263  ```
6264
6265### getPluralStringValue<sup>(deprecated)</sup>
6266
6267getPluralStringValue(resId: number, num: number, callback: _AsyncCallback&lt;string&gt;): void
6268
6269Obtains singular/plural strings based on the specified quantity and resource ID. This API uses an asynchronous callback to return the result.
6270
6271> **NOTE**
6272>
6273> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6274>
6275> This API is supported since API version 9 and is deprecated since API version 18. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6276
6277**Atomic service API**: This API can be used in atomic services since API version 11.
6278
6279**System capability**: SystemCapability.Global.ResourceManager
6280
6281**Parameters**
6282
6283| Name  | Type                       | Mandatory| Description                                                        |
6284| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
6285| resId    | number                      | Yes  | Resource ID.                                                  |
6286| num      | number                      | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html)|
6287| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes  | Callback used to return the obtained singular/plural string.          |
6288
6289**Error codes**
6290
6291For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6292
6293| ID| Error Message                                                    |
6294| -------- | ------------------------------------------------------------ |
6295| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6296| 9001001  | Invalid resource ID.                                         |
6297| 9001002  | No matching resource is found based on the resource ID.      |
6298| 9001006  | The resource is referenced cyclically.                       |
6299
6300**Example**
6301  ```json
6302  // Resource file path: src/main/resources/base/element/plural.json
6303  {
6304    "plural": [
6305      {
6306        "name": "test",
6307        "value": [
6308          {
6309            "quantity": "one",
6310            "value": "%d apple"
6311          },
6312          {
6313            "quantity": "other",
6314            "value": "%d apples"
6315          }
6316        ]
6317      }
6318    ]
6319  }
6320  ```
6321  ```ts
6322  import { BusinessError } from '@kit.BasicServicesKit';
6323
6324  // If num is 1, the single/plural type is one in the English environment.
6325  // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6326  this.context.resourceManager.getPluralStringValue($r("app.plural.test").id, 1,
6327    (error: BusinessError, value: string) => {
6328      if (error != null) {
6329        console.error(`callback getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`);
6330      } else {
6331        console.log(`getPluralStringValue, result: ${value}`);
6332        // Print the output result: getPluralStringValue, result: 1 apple
6333      }
6334    });
6335  ```
6336
6337### getPluralStringValue<sup>(deprecated)</sup>
6338
6339getPluralStringValue(resId: number, num: number): Promise&lt;string&gt;
6340
6341Obtains singular/plural strings based on the specified quantity and resource ID. This API uses a promise to return the result.
6342
6343> **NOTE**
6344>
6345> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6346>
6347> This API is supported since API version 9 and is deprecated since API version 18. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6348
6349**Atomic service API**: This API can be used in atomic services since API version 11.
6350
6351**System capability**: SystemCapability.Global.ResourceManager
6352
6353**Parameters**
6354
6355| Name| Type  | Mandatory| Description                                                        |
6356| ------ | ------ | ---- | ------------------------------------------------------------ |
6357| resId  | number | Yes  | Resource ID.                                                  |
6358| num    | number | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6359
6360**Return value**
6361
6362| Type                 | Description                                                |
6363| --------------------- | ---------------------------------------------------- |
6364| Promise&lt;string&gt; | Promise used to return the obtained singular/plural string.|
6365
6366**Error codes**
6367
6368For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6369
6370| ID| Error Message                                                    |
6371| -------- | ------------------------------------------------------------ |
6372| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6373| 9001001  | Invalid resource ID.                                         |
6374| 9001002  | No matching resource is found based on the resource ID.      |
6375| 9001006  | The resource is referenced cyclically.                       |
6376
6377**Example**
6378  ```json
6379  // Resource file path: src/main/resources/base/element/plural.json
6380  {
6381    "plural": [
6382      {
6383        "name": "test",
6384        "value": [
6385          {
6386            "quantity": "one",
6387            "value": "%d apple"
6388          },
6389          {
6390            "quantity": "other",
6391            "value": "%d apples"
6392          }
6393        ]
6394      }
6395    ]
6396  }
6397  ```
6398  ```ts
6399  import { BusinessError } from '@kit.BasicServicesKit';
6400
6401  // If num is 1, the single/plural type is one in the English environment.
6402  // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6403  this.context.resourceManager.getPluralStringValue($r("app.plural.test").id, 1)
6404    .then((value: string) => {
6405      console.log(`getPluralStringValue, result: ${value}`);
6406      // Print the output result: getPluralStringValue, result: 1 apple
6407    })
6408    .catch((error: BusinessError) => {
6409      console.error(`promise getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`);
6410    });
6411  ```
6412
6413### getPluralStringValue<sup>(deprecated)</sup>
6414
6415getPluralStringValue(resource: Resource, num: number, callback: _AsyncCallback&lt;string&gt;): void
6416
6417Obtains singular/plural strings based on the specified quantity and resource object. This API uses an asynchronous callback to return the result.
6418
6419> **NOTE**
6420>
6421> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6422>
6423> This API is supported since API version 9 and is deprecated since API version 18. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6424
6425**Atomic service API**: This API can be used in atomic services since API version 11.
6426
6427**System capability**: SystemCapability.Global.ResourceManager
6428
6429**Model restriction**: This API can be used only in the stage model.
6430
6431**Parameters**
6432
6433| Name  | Type                       | Mandatory| Description                                                        |
6434| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
6435| resource | [Resource](#resource9)      | Yes  | Resource object.                                                  |
6436| num      | number                      | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html)|
6437| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes  | Callback used to return the obtained singular/plural string.      |
6438
6439**Error codes**
6440
6441For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6442
6443| ID| Error Message                                                    |
6444| -------- | ------------------------------------------------------------ |
6445| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6446| 9001001  | Invalid resource ID.                                         |
6447| 9001002  | No matching resource is found based on the resource ID.      |
6448| 9001006  | The resource is referenced cyclically.                       |
6449
6450**Example**
6451  ```json
6452  // Resource file path: src/main/resources/base/element/plural.json
6453  {
6454    "plural": [
6455      {
6456        "name": "test",
6457        "value": [
6458          {
6459            "quantity": "one",
6460            "value": "%d apple"
6461          },
6462          {
6463            "quantity": "other",
6464            "value": "%d apples"
6465          }
6466        ]
6467      }
6468    ]
6469  }
6470  ```
6471  ```ts
6472  import { resourceManager } from '@kit.LocalizationKit';
6473  import { BusinessError } from '@kit.BasicServicesKit';
6474
6475  let resource: resourceManager.Resource = {
6476    bundleName: "com.example.myapplication",
6477    moduleName: "entry",
6478    id: $r('app.plural.test').id
6479  };
6480  // If num is 1, the single/plural type is one in the English environment.
6481  // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6482  this.context.resourceManager.getPluralStringValue(resource, 1,
6483    (error: BusinessError, value: string) => {
6484      if (error != null) {
6485        console.error(`callback getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`);
6486      } else {
6487        console.log(`getPluralStringValue, result: ${value}`);
6488        // Print the output result: getPluralStringValue, result: 1 apple
6489      }
6490    });
6491  ```
6492
6493### getPluralStringValue<sup>(deprecated)</sup>
6494
6495getPluralStringValue(resource: Resource, num: number): Promise&lt;string&gt;
6496
6497Obtains singular/plural strings based on the specified quantity and resource object. This API uses a promise to return the result.
6498
6499> **NOTE**
6500>
6501> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6502>
6503> This API is supported since API version 9 and is deprecated since API version 18. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6504
6505**Atomic service API**: This API can be used in atomic services since API version 11.
6506
6507**System capability**: SystemCapability.Global.ResourceManager
6508
6509**Model restriction**: This API can be used only in the stage model.
6510
6511**Parameters**
6512
6513| Name  | Type                  | Mandatory| Description                                                        |
6514| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
6515| resource | [Resource](#resource9) | Yes  | Resource object.                                                  |
6516| num      | number                 | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6517
6518**Return value**
6519
6520| Type                 | Description                                                    |
6521| --------------------- | -------------------------------------------------------- |
6522| Promise&lt;string&gt; | Promise used to return the obtained singular/plural string. |
6523
6524**Error codes**
6525
6526For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6527
6528| ID| Error Message                                                    |
6529| -------- | ------------------------------------------------------------ |
6530| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6531| 9001001  | Invalid resource ID.                                         |
6532| 9001002  | No matching resource is found based on the resource ID.      |
6533| 9001006  | The resource is referenced cyclically.                       |
6534
6535**Example**
6536  ```json
6537  // Resource file path: src/main/resources/base/element/plural.json
6538  {
6539    "plural": [
6540      {
6541        "name": "test",
6542        "value": [
6543          {
6544            "quantity": "one",
6545            "value": "%d apple"
6546          },
6547          {
6548            "quantity": "other",
6549            "value": "%d apples"
6550          }
6551        ]
6552      }
6553    ]
6554  }
6555  ```
6556  ```ts
6557  import { resourceManager } from '@kit.LocalizationKit';
6558  import { BusinessError } from '@kit.BasicServicesKit';
6559
6560  let resource: resourceManager.Resource = {
6561    bundleName: "com.example.myapplication",
6562    moduleName: "entry",
6563    id: $r('app.plural.test').id
6564  };
6565  // If num is 1, the single/plural type is one in the English environment.
6566  // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6567  this.context.resourceManager.getPluralStringValue(resource, 1)
6568    .then((value: string) => {
6569      console.log(`getPluralStringValue, result: ${value}`);
6570      // Print the output result: getPluralStringValue, result: 1 apple
6571    })
6572    .catch((error: BusinessError) => {
6573      console.error(`promise getPluralStringValue failed, error code: ${error.code}, message: ${error.message}.`);
6574    });
6575  ```
6576
6577### getPluralStringByName<sup>(deprecated)</sup>
6578
6579getPluralStringByName(resName: string, num: number, callback: _AsyncCallback&lt;string&gt;): void
6580
6581Obtains singular/plural strings based on the specified quantity and resource name. This API uses an asynchronous callback to return the result.
6582
6583> **NOTE**
6584>
6585> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6586>
6587> This API is supported since API version 9 and is deprecated since API version 18. You are advised to use [getIntPluralStringByNameSync](#getintpluralstringbynamesync18) instead.
6588
6589**Atomic service API**: This API can be used in atomic services since API version 11.
6590
6591**System capability**: SystemCapability.Global.ResourceManager
6592
6593**Parameters**
6594
6595| Name  | Type                       | Mandatory| Description                                                        |
6596| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
6597| resName  | string                      | Yes  | Resource name.                                                  |
6598| num      | number                      | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html)|
6599| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;string&gt; | Yes  | Callback used to return the obtained singular/plural string.            |
6600
6601**Error codes**
6602
6603For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6604
6605| ID| Error Message                                                    |
6606| -------- | ------------------------------------------------------------ |
6607| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6608| 9001003  | Invalid resource name.                                       |
6609| 9001004  | No matching resource is found based on the resource name.    |
6610| 9001006  | The resource is referenced cyclically.                       |
6611
6612**Example**
6613  ```json
6614  // Resource file path: src/main/resources/base/element/plural.json
6615  {
6616    "plural": [
6617      {
6618        "name": "test",
6619        "value": [
6620          {
6621            "quantity": "one",
6622            "value": "%d apple"
6623          },
6624          {
6625            "quantity": "other",
6626            "value": "%d apples"
6627          }
6628        ]
6629      }
6630    ]
6631  }
6632  ```
6633  ```ts
6634  import { BusinessError } from '@kit.BasicServicesKit';
6635
6636  // If num is 1, the single/plural type is one in the English environment.
6637  // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6638  this.context.resourceManager.getPluralStringByName("test", 1, (error: BusinessError, value: string) => {
6639    if (error != null) {
6640      console.error(`callback getPluralStringByName failed, error code: ${error.code}, message: ${error.message}.`);
6641    } else {
6642      console.log(`getPluralStringByName, result: ${value}`);
6643      // Print the output result: getPluralStringByName, result: 1 apple
6644    }
6645  });
6646  ```
6647
6648### getPluralStringByName<sup>(deprecated)</sup>
6649
6650getPluralStringByName(resName: string, num: number): Promise&lt;string&gt;
6651
6652Obtains singular/plural strings based on the specified quantity and resource name. This API uses a promise to return the result.
6653
6654> **NOTE**
6655>
6656> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6657>
6658> This API is supported since API version 9 and is deprecated since API version 18. You are advised to use [getIntPluralStringByNameSync](#getintpluralstringbynamesync18) instead.
6659
6660**Atomic service API**: This API can be used in atomic services since API version 11.
6661
6662**System capability**: SystemCapability.Global.ResourceManager
6663
6664**Parameters**
6665
6666| Name | Type  | Mandatory| Description                                                        |
6667| ------- | ------ | ---- | ------------------------------------------------------------ |
6668| resName | string | Yes  | Resource name.                                                  |
6669| num     | number | Yes  | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6670
6671**Return value**
6672
6673| Type                 | Description                                            |
6674| --------------------- | ------------------------------------------------ |
6675| Promise&lt;string&gt; | Promise used to return the result, which is the singular/plural string corresponding to the specified resource name.|
6676
6677**Error codes**
6678
6679For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6680
6681| ID| Error Message                                                    |
6682| -------- | ------------------------------------------------------------ |
6683| 401      | If the input parameter invalid. Possible causes: Incorrect parameter types. |
6684| 9001003  | Invalid resource name.                                       |
6685| 9001004  | No matching resource is found based on the resource name.    |
6686| 9001006  | The resource is referenced cyclically.                       |
6687
6688**Example**
6689  ```json
6690  // Resource file path: src/main/resources/base/element/plural.json
6691  {
6692    "plural": [
6693      {
6694        "name": "test",
6695        "value": [
6696          {
6697            "quantity": "one",
6698            "value": "%d apple"
6699          },
6700          {
6701            "quantity": "other",
6702            "value": "%d apples"
6703          }
6704        ]
6705      }
6706    ]
6707  }
6708  ```
6709  ```ts
6710  import { BusinessError } from '@kit.BasicServicesKit';
6711
6712  // If num is 1, the single/plural type is one in the English environment.
6713  // The quantity field in the resource file indicates the single/plural type. Therefore, the string whose quantity is one is obtained.
6714  this.context.resourceManager.getPluralStringByName("test", 1)
6715    .then((value: string) => {
6716      console.log(`getPluralStringByName, result: ${value}`);
6717      // Print the output result: getPluralStringByName, result: 1 apple
6718    })
6719    .catch((error: BusinessError) => {
6720      console.error(`promise getPluralStringByName failed, error code: ${error.code}, message: ${error.message}.`);
6721    });
6722  ```
6723
6724### getPluralString<sup>(deprecated)</sup>
6725
6726getPluralString(resId: number, num: number): Promise&lt;string&gt;
6727
6728Obtains singular/plural strings based on the specified quantity and resource ID. This API uses a promise to return the result.
6729
6730> **NOTE**
6731>
6732> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6733>
6734> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6735
6736**System capability**: SystemCapability.Global.ResourceManager
6737
6738**Parameters**
6739
6740| Name  | Type    | Mandatory  | Description   |
6741| ----- | ------ | ---- | ----- |
6742| resId | number | Yes   | Resource ID.|
6743| num   | number | Yes   | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).|
6744
6745**Return value**
6746
6747| Type                   | Description                       |
6748| --------------------- | ------------------------- |
6749| Promise&lt;string&gt; | Promise used to return the obtained singular/plural string.|
6750
6751**Example**
6752
6753  ```ts
6754  import { BusinessError } from '@kit.BasicServicesKit';
6755
6756  resourceManager.getResourceManager((error, mgr) => {
6757      mgr.getPluralString($r("app.plural.test").id, 1).then((value: string) => {
6758          let str = value;
6759      }).catch((error: BusinessError) => {
6760          console.error("getPluralString promise error is " + error);
6761      });
6762  });
6763  ```
6764
6765
6766### getPluralString<sup>(deprecated)</sup>
6767
6768getPluralString(resId: number, num: number, callback: AsyncCallback&lt;string&gt;): void
6769
6770Obtains singular/plural strings based on the specified quantity and resource ID. This API uses an asynchronous callback to return the result.
6771
6772> **NOTE**
6773>
6774> Strings distinguish between singular and plural forms in all languages except Chinese. For details, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html).
6775>
6776> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [getIntPluralStringValueSync](#getintpluralstringvaluesync18) instead.
6777
6778**System capability**: SystemCapability.Global.ResourceManager
6779
6780**Parameters**
6781
6782| Name     | Type                         | Mandatory  | Description                             |
6783| -------- | --------------------------- | ---- | ------------------------------- |
6784| resId    | number                      | Yes   | Resource ID.                          |
6785| num      | number                      | Yes   | Quantity value, which is used to obtain the corresponding string representation based on the current language's plural rules. For details about the plural rules of a language, see [Language Plural Rules](https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html)|
6786| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;string&gt; | Yes   | Callback used to return the obtained singular/plural string.|
6787
6788**Example**
6789
6790  ```ts
6791  import { resourceManager } from '@kit.LocalizationKit';
6792
6793  resourceManager.getResourceManager((error, mgr) => {
6794      mgr.getPluralString($r("app.plural.test").id, 1, (error: Error, value: string) => {
6795          if (error != null) {
6796              console.error("error is " + error);
6797          } else {
6798              let str = value;
6799          }
6800      });
6801  });
6802  ```
6803### getBoolean<sup>(deprecated)</sup>
6804
6805getBoolean(resource: Resource): boolean
6806
6807Obtains a Boolean value based on the specified resource object. This API returns the result synchronously.
6808
6809> **NOTE**
6810>
6811> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getBooleanByName](#getbooleanbyname9) or [getBoolean](#getboolean9) instead.
6812
6813**Atomic service API**: This API can be used in atomic services since API version 11.
6814
6815**System capability**: SystemCapability.Global.ResourceManager
6816
6817**Model restriction**: This API can be used only in the stage model.
6818
6819**Parameters**
6820
6821| Name     | Type                    | Mandatory  | Description  |
6822| -------- | ---------------------- | ---- | ---- |
6823| resource | [Resource](#resource9) | Yes   | Resource object.|
6824
6825**Return value**
6826
6827| Type     | Description               |
6828| ------- | ----------------- |
6829| boolean | Boolean value.|
6830
6831**Error codes**
6832
6833For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6834
6835| ID| Error Message|
6836| -------- | ---------------------------------------- |
6837| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
6838| 9001001  | Invalid resource ID.                       |
6839| 9001002  | No matching resource is found based on the resource ID.         |
6840| 9001006  | The resource is referenced cyclically.            |
6841
6842**Example**
6843  ```json
6844  // Resource file path: src/main/resources/base/element/boolean.json
6845  {
6846    "boolean": [
6847      {
6848        "name": "boolean_test",
6849        "value": true
6850      }
6851    ]
6852  }
6853  ```
6854  ```ts
6855  import { resourceManager } from '@kit.LocalizationKit';
6856  import { BusinessError } from '@kit.BasicServicesKit';
6857
6858  let resource: resourceManager.Resource = {
6859    bundleName: "com.example.myapplication",
6860    moduleName: "entry",
6861    id: $r('app.boolean.boolean_test').id
6862  };
6863  try {
6864    let boolTest = this.context.resourceManager.getBoolean(resource);
6865    console.log(`getBoolean, result: ${boolTest}`);
6866    // Print the output result: getBoolean, result: true
6867  } catch (error) {
6868    let code = (error as BusinessError).code;
6869    let message = (error as BusinessError).message;
6870    console.error(`getBoolean failed, error code: ${code}, message: ${message}.`);
6871  }
6872  ```
6873### getNumber<sup>(deprecated)</sup>
6874
6875getNumber(resource: Resource): number
6876
6877Obtains an integer or float number based on the specified resource object. This API returns the result synchronously.
6878
6879> **NOTE**
6880>
6881> This API is supported since API version 9 and is deprecated since API version 20. You are advised to use [getNumberByName](#getnumberbyname9) or [getNumber](#getnumber9) instead.
6882
6883**Atomic service API**: This API can be used in atomic services since API version 11.
6884
6885**System capability**: SystemCapability.Global.ResourceManager
6886
6887**Model restriction**: This API can be used only in the stage model.
6888
6889**Parameters**
6890
6891| Name     | Type                    | Mandatory  | Description  |
6892| -------- | ---------------------- | ---- | ---- |
6893| resource | [Resource](#resource9) | Yes   | Resource object.|
6894
6895**Return value**
6896
6897| Type    | Description             |
6898| ------ | --------------- |
6899| number | Integer or float number.<br>An integer indicates the original value, and a float number without a unit indicates the original value and a float number with the unit of vp or fp indicates the px value.|
6900
6901**Error codes**
6902
6903For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6904
6905| ID| Error Message|
6906| -------- | ---------------------------------------- |
6907| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
6908| 9001001  | Invalid resource ID.                       |
6909| 9001002  | No matching resource is found based on the resource ID.         |
6910| 9001006  | The resource is referenced cyclically.            |
6911
6912**Example**
6913  ```json
6914  // Resource file path: src/main/resources/base/element/integer.json
6915  {
6916    "integer": [
6917      {
6918        "name": "integer_test",
6919        "value": 100
6920      }
6921    ]
6922  }
6923  ```
6924
6925  ```ts
6926  import { resourceManager } from '@kit.LocalizationKit';
6927  import { BusinessError } from '@kit.BasicServicesKit';
6928
6929  let resource: resourceManager.Resource = {
6930    bundleName: "com.example.myapplication",
6931    moduleName: "entry",
6932    id: $r('app.integer.integer_test').id
6933  };
6934
6935  try {
6936    let intValue = this.context.resourceManager.getNumber(resource);
6937    console.log(`getNumber, int value: ${intValue}`);
6938    // Print the output result: getNumber, int value: 100
6939  } catch (error) {
6940    let code = (error as BusinessError).code;
6941    let message = (error as BusinessError).message;
6942    console.error(`getNumber failed, error code: ${code}, message: ${message}.`);
6943  }
6944  ```
6945### getColorSync<sup>(deprecated)</sup>
6946
6947getColorSync(resource: Resource): number
6948
6949Obtains a color value based on the specified resource object. This API returns the result synchronously.
6950
6951> **NOTE**
6952>
6953> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getColorByNameSync](#getcolorbynamesync10) or [getColorSync](#getcolorsync10) instead.
6954
6955**Atomic service API**: This API can be used in atomic services since API version 11.
6956
6957**System capability**: SystemCapability.Global.ResourceManager
6958
6959**Model restriction**: This API can be used only in the stage model.
6960
6961**Parameters**
6962
6963| Name     | Type                    | Mandatory  | Description  |
6964| -------- | ---------------------- | ---- | ---- |
6965| resource | [Resource](#resource9) | Yes   | Resource object.|
6966
6967**Return value**
6968
6969| Type    | Description              |
6970| ------ | ---------------- |
6971| number | Color value (decimal) corresponding to the specified resource object.|
6972
6973**Error codes**
6974
6975For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
6976
6977| ID| Error Message|
6978| -------- | ---------------------------------------- |
6979| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
6980| 9001001  | Invalid resource ID.                       |
6981| 9001002  | No matching resource is found based on the resource ID.         |
6982| 9001006  | The resource is referenced cyclically.            |
6983
6984**Example**
6985  ```json
6986  // Resource file path: src/main/resources/base/element/color.json
6987  {
6988    "color": [
6989      {
6990        "name": "test",
6991        "value": "#FFFFFF"
6992      }
6993    ]
6994  }
6995  ```
6996  ```ts
6997  import { resourceManager } from '@kit.LocalizationKit';
6998  import { BusinessError } from '@kit.BasicServicesKit';
6999
7000  let resource: resourceManager.Resource = {
7001    bundleName: "com.example.myapplication",
7002    moduleName: "entry",
7003    id: $r('app.color.test').id
7004  };
7005  try {
7006    let colorValue = this.context.resourceManager.getColorSync(resource);
7007    console.log(`getColorSync, result: ${colorValue}`);
7008    // Print the output result: getColorSync, result: 4294967295
7009  } catch (error) {
7010    let code = (error as BusinessError).code;
7011    let message = (error as BusinessError).message;
7012    console.error(`getColorSync failed, error code: ${code}, message: ${message}.`);
7013  }
7014  ```
7015### getColor<sup>(deprecated)</sup>
7016
7017getColor(resource: Resource, callback: _AsyncCallback&lt;number&gt;): void
7018
7019Obtains a color value based on the specified resource object. This API uses an asynchronous callback to return the result.
7020
7021> **NOTE**
7022>
7023> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getColorByName](#getcolorbyname10) or [getColor](#getcolor10) instead.
7024
7025**Atomic service API**: This API can be used in atomic services since API version 11.
7026
7027**System capability**: SystemCapability.Global.ResourceManager
7028
7029**Model restriction**: This API can be used only in the stage model.
7030
7031**Parameters**
7032
7033| Name     | Type                         | Mandatory  | Description             |
7034| -------- | --------------------------- | ---- | --------------- |
7035| resource | [Resource](#resource9)      | Yes   | Resource object.           |
7036| callback | [_AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback)&lt;number&gt; | Yes   | Callback used to return the color value (decimal).|
7037
7038**Error codes**
7039
7040For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
7041
7042| ID| Error Message|
7043| -------- | ---------------------------------------- |
7044| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
7045| 9001001  | Invalid resource ID.                       |
7046| 9001002  | No matching resource is found based on the resource ID.         |
7047| 9001006  | The resource is referenced cyclically.            |
7048
7049**Example**
7050  ```json
7051  // Resource file path: src/main/resources/base/element/color.json
7052  {
7053    "color": [
7054      {
7055        "name": "test",
7056        "value": "#FFFFFF"
7057      }
7058    ]
7059  }
7060  ```
7061  ```ts
7062  import { resourceManager } from '@kit.LocalizationKit';
7063  import { BusinessError } from '@kit.BasicServicesKit';
7064
7065  let resource: resourceManager.Resource = {
7066    bundleName: "com.example.myapplication",
7067    moduleName: "entry",
7068    id: $r('app.color.test').id
7069  };
7070  this.context.resourceManager.getColor(resource, (error: BusinessError, value: number) => {
7071    if (error != null) {
7072      console.error(`callback getColor failed, error code: ${error.code}, message: ${error.message}.`);
7073    } else {
7074      console.log(`getColor, result: ${value}`);
7075      // Print the output result: getColor, result: 4294967295
7076    }
7077  });
7078  ```
7079
7080### getColor<sup>(deprecated)</sup>
7081
7082getColor(resource: Resource): Promise&lt;number&gt;
7083
7084Obtains a color value based on the specified resource object. This API uses a promise to return the result.
7085
7086> **NOTE**
7087>
7088> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [getColorByName] (#getcolorbyname10-1) or [getColor] (#getcolor10-1) instead.
7089
7090**Atomic service API**: This API can be used in atomic services since API version 11.
7091
7092**System capability**: SystemCapability.Global.ResourceManager
7093
7094**Model restriction**: This API can be used only in the stage model.
7095
7096**Parameters**
7097
7098| Name     | Type                    | Mandatory  | Description  |
7099| -------- | ---------------------- | ---- | ---- |
7100| resource | [Resource](#resource9) | Yes   | Resource object.|
7101
7102**Return value**
7103
7104| Type                   | Description              |
7105| --------------------- | ---------------- |
7106| Promise&lt;number&gt; | Promise used to return the color value (decimal).|
7107
7108**Error codes**
7109
7110For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
7111
7112| ID| Error Message|
7113| -------- | ---------------------------------------- |
7114| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
7115| 9001001  | Invalid resource ID.                       |
7116| 9001002  | No matching resource is found based on the resource ID.         |
7117| 9001006  | The resource is referenced cyclically.            |
7118
7119**Example**
7120  ```json
7121  // Resource file path: src/main/resources/base/element/color.json
7122  {
7123    "color": [
7124      {
7125        "name": "test",
7126        "value": "#FFFFFF"
7127      }
7128    ]
7129  }
7130  ```
7131  ```ts
7132  import { resourceManager } from '@kit.LocalizationKit';
7133  import { BusinessError } from '@kit.BasicServicesKit';
7134
7135  let resource: resourceManager.Resource = {
7136    bundleName: "com.example.myapplication",
7137    moduleName: "entry",
7138    id: $r('app.color.test').id
7139  };
7140  this.context.resourceManager.getColor(resource)
7141    .then((value: number) => {
7142      console.log(`getColor, result: ${value}`);
7143      // Print the output result: getColor, result: 4294967295
7144    })
7145    .catch((error: BusinessError) => {
7146      console.error(`promise getColor failed, error code: ${error.code}, message: ${error.message}.`);
7147    });
7148  ```
7149### getSymbol<sup>(deprecated)</sup>
7150getSymbol(resource: Resource): number
7151
7152Obtains the Unicode of a [symbol](https://developer.huawei.com/consumer/en/design/harmonyos-symbol) based on the specified resource object. This API returns the result synchronously.
7153
7154> **NOTE**
7155>
7156> This API is supported since API version 11 and is deprecated since API version 20. You are advised to use [getSymbolByName](#getsymbolbyname11) or [getSymbol](#getsymbol11) instead.
7157
7158**Atomic service API**: This API can be used in atomic services since API version 11.
7159
7160**System capability**: SystemCapability.Global.ResourceManager
7161
7162**Model restriction**: This API can be used only in the stage model.
7163
7164**Parameters**
7165
7166| Name     | Type                    | Mandatory  | Description  |
7167| -------- | ---------------------- | ---- | ---- |
7168| resource | [Resource](#resource9) | Yes   | Resource object.|
7169
7170**Return value**
7171
7172| Type    | Description         |
7173| ------ | ----------- |
7174| number | Unicode code (decimal) of the symbol.|
7175
7176**Error codes**
7177
7178For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md) and [Universal Error Codes](../errorcode-universal.md).
7179
7180| ID| Error Message|
7181| -------- | ---------------------------------------- |
7182| 401 | If the input parameter invalid. Possible causes: Incorrect parameter types.               |
7183| 9001001  | Invalid resource ID.                       |
7184| 9001002  | No matching resource is found based on the resource ID.         |
7185| 9001006  | The resource is referenced cyclically.            |
7186
7187**Example**
7188  ```ts
7189  import { resourceManager } from '@kit.LocalizationKit';
7190  import { BusinessError } from '@kit.BasicServicesKit';
7191
7192  let resource: resourceManager.Resource = {
7193    bundleName: "com.example.myapplication",
7194    moduleName: "entry",
7195    id: $r('sys.symbol.message').id
7196  };
7197  try {
7198    let symbolValue = this.context.resourceManager.getSymbol(resource);
7199    console.log(`getSymbol, result: ${symbolValue}`);
7200    // Print the output result: getSymbol, result: 983183
7201  } catch (error) {
7202    let code = (error as BusinessError).code;
7203    let message = (error as BusinessError).message;
7204    console.error(`getSymbol failed, error code: ${code}, message: ${message}.`);
7205  }
7206  ```
7207
7208### getRawFile<sup>(deprecated)</sup>
7209
7210getRawFile(path: string, callback: AsyncCallback&lt;Uint8Array&gt;): void
7211
7212Obtains the content of a raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
7213
7214> **NOTE**
7215>
7216> This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getRawFileContent](#getrawfilecontent9) instead.
7217
7218**System capability**: SystemCapability.Global.ResourceManager
7219
7220**Parameters**
7221
7222| Name     | Type                             | Mandatory  | Description                     |
7223| -------- | ------------------------------- | ---- | ----------------------- |
7224| path     | string                          | Yes   | Path of the raw file.            |
7225| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;Uint8Array&gt; | Yes   | Callback used to return the raw file content.|
7226
7227**Example**
7228  ```ts
7229  import { resourceManager } from '@kit.LocalizationKit';
7230
7231  resourceManager.getResourceManager((error, mgr) => {
7232      mgr.getRawFile("test.txt", (error: Error, value: Uint8Array) => {
7233          if (error != null) {
7234              console.error("error is " + error);
7235          } else {
7236              let rawFile = value;
7237          }
7238      });
7239  });
7240  ```
7241
7242
7243### getRawFile<sup>(deprecated)</sup>
7244
7245getRawFile(path: string): Promise&lt;Uint8Array&gt;
7246
7247Obtains the content of a raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
7248
7249> **NOTE**
7250>
7251> This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getRawFileContent](#getrawfilecontent9-1) instead.
7252
7253**System capability**: SystemCapability.Global.ResourceManager
7254
7255**Parameters**
7256
7257| Name | Type    | Mandatory  | Description         |
7258| ---- | ------ | ---- | ----------- |
7259| path | string | Yes   | Path of the raw file.|
7260
7261**Return value**
7262
7263| Type                       | Description         |
7264| ------------------------- | ----------- |
7265| Promise&lt;Uint8Array&gt; | Promise used to return the raw file content.|
7266
7267**Example**
7268  ```ts
7269  import { BusinessError } from '@kit.BasicServicesKit';
7270
7271  resourceManager.getResourceManager((error, mgr) => {
7272      mgr.getRawFile("test.txt").then((value: Uint8Array) => {
7273          let rawFile = value;
7274      }).catch((error: BusinessError) => {
7275          console.error("getRawFile promise error is " + error);
7276      });
7277  });
7278  ```
7279
7280
7281### getRawFileDescriptor<sup>(deprecated)</sup>
7282
7283getRawFileDescriptor(path: string, callback: AsyncCallback&lt;RawFileDescriptor&gt;): void
7284
7285Obtains the fd of the raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
7286
7287> **NOTE**
7288>
7289> This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getRawFd](#getrawfd9) instead.
7290
7291**System capability**: SystemCapability.Global.ResourceManager
7292
7293**Parameters**
7294
7295| Name     | Type                                      | Mandatory  | Description                              |
7296| -------- | ---------------------------------------- | ---- | -------------------------------- |
7297| path     | string                                   | Yes   | Path of the raw file.                     |
7298| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;[RawFileDescriptor](#rawfiledescriptor9)&gt; | Yes   | Callback used to return the obtained fd.|
7299
7300**Example**
7301  ```ts
7302  import { resourceManager } from '@kit.LocalizationKit';
7303
7304  resourceManager.getResourceManager((error, mgr) => {
7305      mgr.getRawFileDescriptor("test.txt", (error: Error, value: resourceManager.RawFileDescriptor) => {
7306          if (error != null) {
7307              console.error("error is " + error);
7308          } else {
7309              let fd = value.fd;
7310              let offset = value.offset;
7311              let length = value.length;
7312          }
7313      });
7314  });
7315  ```
7316
7317### getRawFileDescriptor<sup>(deprecated)</sup>
7318
7319getRawFileDescriptor(path: string): Promise&lt;RawFileDescriptor&gt;
7320
7321Obtains the fd of the raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
7322
7323> **NOTE**
7324>
7325> This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [getRawFd](#getrawfd9-1) instead.
7326
7327**System capability**: SystemCapability.Global.ResourceManager
7328
7329**Parameters**
7330
7331| Name | Type    | Mandatory  | Description         |
7332| ---- | ------ | ---- | ----------- |
7333| path | string | Yes   | Path of the raw file.|
7334
7335**Return value**
7336
7337| Type                                      | Description                 |
7338| ---------------------------------------- | ------------------- |
7339| Promise&lt;[RawFileDescriptor](#rawfiledescriptor9)&gt; | Promise used to return the obtained fd.|
7340
7341**Example**
7342  ```ts
7343  import { BusinessError } from '@kit.BasicServicesKit';
7344
7345  resourceManager.getResourceManager((error, mgr) => {
7346      mgr.getRawFileDescriptor("test.txt").then((value: resourceManager.RawFileDescriptor) => {
7347          let fd = value.fd;
7348          let offset = value.offset;
7349          let length = value.length;
7350      }).catch((error: BusinessError) => {
7351          console.error("getRawFileDescriptor promise error is " + error);
7352      });
7353  });
7354  ```
7355
7356### closeRawFileDescriptor<sup>(deprecated)</sup>
7357
7358closeRawFileDescriptor(path: string, callback: AsyncCallback&lt;void&gt;): void
7359
7360Closes the fd of the raw file in the **resources/rawfile** directory. This API uses an asynchronous callback to return the result.
7361
7362> **NOTE**
7363>
7364> This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [closeRawFd](#closerawfd9) instead.
7365
7366**System capability**: SystemCapability.Global.ResourceManager
7367
7368**Parameters**
7369
7370
7371
7372| Name     | Type                       | Mandatory  | Description         |
7373| -------- | ------------------------- | ---- | ----------- |
7374| path     | string                    | Yes   | Path of the raw file.|
7375| callback | [AsyncCallback](#asynccallbackdeprecated)&lt;void&gt; | Yes   | Callback used to return the result. If the operation is successful, **err** is **undefined**. Otherwise, **err** is an error object.|
7376
7377**Example**
7378  ```ts
7379  import { resourceManager } from '@kit.LocalizationKit';
7380
7381  resourceManager.getResourceManager((error, mgr) => {
7382      mgr.closeRawFileDescriptor("test.txt", (error: Error) => {
7383          if (error != null) {
7384              console.error("error is " + error);
7385          }
7386      });
7387  });
7388  ```
7389
7390### closeRawFileDescriptor<sup>(deprecated)</sup>
7391
7392closeRawFileDescriptor(path: string): Promise&lt;void&gt;
7393
7394Closes the fd of the raw file in the **resources/rawfile** directory. This API uses a promise to return the result.
7395
7396> **NOTE**
7397>
7398> This API is supported since API version 8 and is deprecated since API version 9. You are advised to use [closeRawFd](#closerawfd9-1) instead.
7399
7400**System capability**: SystemCapability.Global.ResourceManager
7401
7402**Parameters**
7403
7404| Name | Type    | Mandatory  | Description         |
7405| ---- | ------ | ---- | ----------- |
7406| path | string | Yes   | Path of the raw file.|
7407
7408**Return value**
7409
7410| Type                 | Description  |
7411| ------------------- | ---- |
7412| Promise&lt;void&gt; | Promise that returns no value.|
7413
7414**Example**
7415  ```ts
7416  import { resourceManager } from '@kit.LocalizationKit';
7417
7418  resourceManager.getResourceManager((error, mgr) => {
7419      mgr.closeRawFileDescriptor("test.txt");
7420  });
7421  ```
7422
7423## resourceManager.getSystemResourceManager<sup>(deprecated)</sup>
7424
7425getSystemResourceManager(): ResourceManager
7426
7427Obtains a **ResourceManager** object.
7428
7429> **NOTE**
7430>
7431> The **Configuration** field in the **ResourceManager** object obtained via this API uses the default value, which is as follows:
7432> {"locale": "", "direction": -1, "deviceType": -1, "screenDensity": 0, "colorMode": 1, "mcc": 0, "mnc": 0}.
7433>
7434> This API is supported since API version 10 and is deprecated since API version 20. You are advised to use [resourceManager.getSysResourceManager](#resourcemanagergetsysresourcemanager20) instead.
7435
7436**Atomic service API**: This API can be used in atomic services since API version 11.
7437
7438**System capability**: SystemCapability.Global.ResourceManager
7439
7440**Return value**
7441
7442| Type                                      | Description                |
7443| ---------------------------------------- | ------------------ |
7444| [ResourceManager](#resourcemanager) | **ResourceManager** object.|
7445
7446**Error codes**
7447
7448For details about the error codes, see [Resource Manager Error Codes](errorcode-resource-manager.md).
7449
7450| ID| Error Message|
7451| -------- | ---------------------------------------- |
7452| 9001009  | Failed to access the system resource. which is not mapped to application sandbox, This error code will be thrown. |
7453
7454**Example**
7455  ```js
7456import { resourceManager } from '@kit.LocalizationKit';
7457import { BusinessError } from '@kit.BasicServicesKit';
7458
7459  try {
7460    let systemResourceManager = resourceManager.getSystemResourceManager();
7461    systemResourceManager.getStringValue($r('sys.string.ohos_lab_vibrate').id).then((value: string) => {
7462      let str = value;
7463    }).catch((error: BusinessError) => {
7464      console.error("systemResourceManager getStringValue promise error is " + error);
7465    });
7466  } catch (error) {
7467    let code = (error as BusinessError).code;
7468    let message = (error as BusinessError).message;
7469    console.error(`getSystemResourceManager failed, error code: ${code}, message: ${message}.`);
7470  }
7471  ```
7472
7473## AsyncCallback<sup>(deprecated)</sup>
7474
7475  ```ts
7476  AsyncCallback<T> {
7477    (err: Error, data: T): void;
7478  }
7479  ```
7480
7481Defines an asynchronous callback that carries an error parameter and asynchronous return value.
7482
7483> **NOTE**
7484>
7485> This API is supported since API version 6 and is deprecated since API version 9. You are advised to use [AsyncCallback](../apis-basic-services-kit/js-apis-base.md#asynccallback) instead.
7486
7487**System capability**: SystemCapability.Global.ResourceManager
7488
7489| Name| Type                                                        | Mandatory| Description                        |
7490| ---- | ------------------------------------------------------------ | ---- | ---------------------------- |
7491| err  | Error | Yes  | Error message returned when the API fails to be called.|
7492| data | T     | Yes  | Callback invoked when the API is called.|
7493
7494## Appendix
7495
7496- Content of the **app.string.test** file:
7497
7498    ```json
7499    // Resource file path: src/main/resources/base/element/string.json
7500    {
7501      "string": [
7502        {
7503          "name": "test",
7504          "value": "I'm a test string resource."
7505        }
7506      ]
7507    }
7508    ```
7509
7510    ```json
7511    // Resource file path: src/main/resources/base/element/string.json
7512    {
7513      "string": [
7514        {
7515          "name": "test",
7516          "value": "I'm a %1$s, format int: %2$d, format float: %3$f."
7517        }
7518      ]
7519    }
7520    ```
7521
7522- Content of the **app.strarray.test** file:
7523
7524    ```json
7525    // Resource file path: src/main/resources/base/element/strarray.json
7526    {
7527      "strarray": [
7528        {
7529          "name": "test",
7530          "value": [
7531            {
7532              "value": "I'm one of the array's values."
7533            }
7534          ]
7535        }
7536      ]
7537    }
7538    ```
7539
7540- Content of the **app.plural.test** file:
7541    ```json
7542    // Resource file path: src/main/resources/base/element/plural.json
7543    {
7544      "plural": [
7545        {
7546          "name": "test",
7547          "value": [
7548            {
7549              "quantity": "one",
7550              "value": "%d apple"
7551            },
7552            {
7553              "quantity": "other",
7554              "value": "%d apples"
7555            }
7556          ]
7557        }
7558      ]
7559    }
7560    ```
7561
7562- Content of the **app.plural.format_test** file:
7563
7564    ```json
7565    // Resource file path: src/main/resources/base/element/plural.json
7566    {
7567      "plural": [
7568        {
7569          "name": "format_test",
7570          "value": [
7571            {
7572              "quantity": "one",
7573              "value": "There is %d apple in the %s, the total amount is %f kg."
7574            },
7575            {
7576              "quantity": "other",
7577              "value": "There are %d apples in the %s, the total amount is %f kg."
7578            }
7579          ]
7580        }
7581      ]
7582    }
7583    ```
7584
7585- Content of the **app.boolean.boolean_test** file:
7586    ```json
7587    // Resource file path: src/main/resources/base/element/boolean.json
7588    {
7589      "boolean": [
7590        {
7591          "name": "boolean_test",
7592          "value": true
7593        }
7594      ]
7595    }
7596    ```
7597
7598- Content of the **integer_test** and **float_test** files:
7599    ```json
7600    // Resource file path: src/main/resources/base/element/integer.json
7601    {
7602      "integer": [
7603        {
7604          "name": "integer_test",
7605          "value": 100
7606        }
7607      ]
7608    }
7609    ```
7610
7611    ```json
7612    // Resource file path: src/main/resources/base/element/float.json
7613    {
7614      "float": [
7615        {
7616          "name": "float_test",
7617          "value": "30.6vp"
7618        }
7619      ]
7620    }
7621    ```
7622- Content of the **app.color.test** file:
7623    ```json
7624    // Resource file path: src/main/resources/base/element/color.json
7625    {
7626      "color": [
7627        {
7628          "name": "test",
7629          "value": "#FFFFFF"
7630        }
7631      ]
7632    }
7633    ```
7634