The **Context** object is created in a **featureAbility** and returned through its **getContext()** method. Therefore, you must import the **@ohos.ability.featureAbility** package before using the Context module. An example is as follows:
Obtains the local root directory of the application. If this method is called for the first time, a root directory is created. This method uses a callback to return the result.
Obtains the local root directory of the application. If this method is called for the first time, a root directory is created. This method uses a promise to return the result.
- Parameters
None
- Return values
| Type| Description|
| --------------- | -------------------- |
| Promise<string> | Promise used to return the local root directory of the application.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| permission | Read-only| string | Yes| Name of the permission to verify.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| Promise<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
Obtains the **ohos.bundle.ElementName** object of the current ability. This method is available only to Page abilities. It uses a callback to return the result.
Obtains the **ohos.bundle.ElementName** object of the current ability. This method is available only to Page abilities. It uses a promise to return the result.
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Applicable Devices
| API | Phone| Tablet| Smart TV| Wearable| Lite Wearable|
| events | Read-only| Array\<string> | Yes| Common events to subscribe to.|
| publisherPermission | Read-only| string | No| Permission required for the publisher.|
| publisherDeviceId | Read-only| string | No| Device ID. The value must be the ID of an existing device on the same network.|
| userId | Read-only| number | No| User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Read-only| number | No| Subscriber priority. The value ranges from -100 to 1000.|
## <span id = "CommonEventData">CommonEventData</span>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result.
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result.
- Example
```js
varsubscriber;// Used to save the created subscriber object for subsequent subscription and unsubscription.
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result.
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result.
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Permission to read the URI.|
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Permission to write the URI.|
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Whether to return the result to the ability.|
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Whether abilities on the local device can be migrated to a remote device.|
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Whether a component belongs to OHOS.|
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Whether to enable an ability.|
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Permission to make the URI persist.|
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Permission to authenticate prefix URI.|
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Support for the startup across multiple devices in a distributed scheduler.|
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Functionality of using the Service template is enabled regardless of whether the host application is started.|
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Whether the migration is reversible.|
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | A demand for the installation of a specific function.|
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | A demand for the installation of a specific function in background mode.|
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | An instruction for clearing other tasks. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | An instruction for creating a task on the history task stack.|
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | An existing instance of the ability to start will be reused if it is already at the top of the task stack. Otherwise, a new ability instance is created.|
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.|
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.|
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.|
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.|
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.|
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.|
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.|
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.|
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.|
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.|
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.|
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.|
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.|
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.|
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
| type | Readable and writable| SlotType | Yes| Notification slot type.|
| level | Readable and writable| number | No| Notification level. If this parameter is not set, the default value is used based on the notification slot type.|
| desc | Readable and writable| string | No| Description of the notification slot.|
| badgeFlag | Readable and writable| boolean | No| Whether to display the badge.|
| bypassDnd | Readable and writable| boolean | No| Whether to bypass the system do-not-disturb (DND) setting.|
| lockscreenVisibility | Readable and writable| boolean | No| How the notification is displayed on the locked screen.|
| vibrationEnabled | Readable and writable| boolean | No| Whether vibration is enabled for the notification.|
| slotType | Read-only| slotType | Yes| Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| callback | Read-only| AsyncCallback\<NotificationSlot\> | Yes| Callback used to return the result.|
| slotType | Read-only| slotType | Yes| Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| SlotType | Read-only| SlotType | Yes| Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| callback | Read-only| AsyncCallback\<void\> | Yes| Callback used to return the result.|
| SlotType | Read-only| SlotType | Yes| Type of the notification slot, which can be used for social communication, service information, content consultation, and other purposes.|
| want | Read-only| [Want](#Want)| Yes| Information about the ability to start.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
| deviceId | Read-only| string | No| ID of the device running the ability to start.|
| bundleName | Read-only| string | No| Bundle name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| abilityName | Read-only| string | No| Name of the ability to start. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can directly match the specified ability.|
| uri | Read-only| string | No| URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read-only| string | No| MIME type, for example, **text/plain** or **image/***.|
| flags | Read-only| number | No| How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](#flags).|
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI.|
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI.|
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability.|
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device.|
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS.|
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability.|
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.|
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.|
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler.|
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.|
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible.|
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed.|
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed.|
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object passed to **ohos.app.Context#startAbility** and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Creates a mission on the historical mission stack.|
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
## AbilityStartSetting
Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**.
The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**.