1# Context 2 3> **NOTE** 4> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 5 6 7Provides the context for running code, including **applicationInfo** and **resourceManager**. 8 9## Usage 10 11 12You must extend **AbilityContext** to implement this module. 13 14 15## Attributes 16 17**System capability**: SystemCapability.Ability.AbilityRuntime.Core 18 19| Name| Type| Readable| Writable| Description| 20| -------- | -------- | -------- | -------- | -------- | 21| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.| 22| applicationInfo | ApplicationInfo | Yes| No| Information about the application.| 23| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.| 24| tempDir | string | Yes| No| Temporary file directory of the application.| 25| filesDir | string | Yes| No| File directory of the application on the internal storage.| 26| databaseDir | string | Yes| No| Storage directory of local data.| 27| storageDir | string | Yes| No| Storage directory of lightweight data.| 28| bundleCodeDir | string | Yes| No| Application installation path.| 29| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.| 30| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.| 31 32 33## Context.createBundleContext 34 35createBundleContext(bundleName: string): Context; 36 37Creates a context for a given application. 38 39**System capability**: SystemCapability.Ability.AbilityRuntime.Core 40 41**Parameters** 42 43| Name| Type| Mandatory| Description| 44| -------- | -------- | -------- | -------- | 45| bundleName | string | Yes| Application bundle name.| 46 47**Return value** 48 49| Type| Description| 50| -------- | -------- | 51| Context | Context created.| 52 53**Example** 54 55 ```js 56 let test = "com.example.test"; 57 let context = this.context.createBundleContext(test); 58 ``` 59 60 61## Context.getApplicationContext 62 63getApplicationContext(): Context; 64 65Obtains the context of this application. 66 67**System capability**: SystemCapability.Ability.AbilityRuntime.Core 68 69**Return value** 70 71| Type| Description| 72| -------- | -------- | 73| Context | Context obtained.| 74 75**Example** 76 77 ```js 78 // This part is mandatory. 79 let context = this.context.getApplicationContext(); 80 ``` 81 82 83 84> **NOTE** 85> 86> Currently, API version 9 is a Canary version. 87 88## Context.switchArea 89 90switchArea(mode: AreaMode): void 91 92Switches the file area mode. 93 94**System capability**: SystemCapability.Ability.AbilityRuntime.Core 95 96**Parameters** 97 98| Name| Type | Mandatory| Description | 99| ------ | --------------------- | ---- | -------------- | 100| mode | [AreaMode](#AreaMode) | Yes | File area mode.| 101 102**Example** 103 104```js 105var areaMode = 0 106this.context.switchArea(areaMode); 107``` 108 109## AreaMode 110 111Describes the file area mode. 112 113**System capability**: SystemCapability.Ability.AbilityRuntime.Core 114 115| Name| Type| Value | 116| ---- | -------- | ---- | 117| EL1 | number | 0 | 118| EL2 | number | 1 | 119