The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs of this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterV9](js-apis-system-parameterV9.md) instead.
> - 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.
> - This is a system API and cannot be called by third-party applications.
> - The APIs provided by this module are system APIs.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions.
## Modules to Import
```ts
importparameterfrom'@ohos.systemparameter'
importsystemparameterfrom'@ohos.systemparameter'
```
## parameter.getSync
## systemparameter.getSync<sup>(deprecated)</sup>
getSync(key: string, def?: string): string
Obtains the value of the attribute with the specified key.
Obtains the value of the system parameter with the specified key.
@@ -23,32 +30,31 @@ Obtains the value of the attribute with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| key | string | Yes| Key of the system parameter.|
| def | string | No| Default value.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | System attribute value. If the specified key does not exist, the default value is returned. If no default value has been set, an empty string will be returned.|
| string | Value of the system parameter. If the specified key does not exist, the default value is returned. If no default value has been set, an empty string will be returned.|
@@ -157,25 +160,29 @@ Sets a value for the attribute with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| value | string | Yes| System attribute value to set.|
| key | string | Yes| Key of the system parameter.|
| value | string | Yes| Value of the system parameter to set.|
> **NOTE**
>
> - This API can be used only for setting parameters of system applications.
> - SELinux and DAC rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
@@ -183,15 +190,20 @@ Sets a value for the attribute with the specified key. This API uses an asynchro
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| value | string | Yes| System attribute value to set.|
| key | string | Yes| Key of the system parameter.|
| value | string | Yes| Value of the system parameter to set.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
> **NOTE**
>
> - This API can be used only for setting parameters of system applications.
> - SELinux and discretionary access control (DAC) rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
@@ -215,8 +226,8 @@ Sets a value for the attribute with the specified key. This API uses a promise t
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.|
| value| string | Yes| System attribute value to set.|
| key | string | Yes| Key of the system parameter.|
| value| string | Yes| Value of the system parameter to set.|
**Return value**
...
...
@@ -224,11 +235,16 @@ Sets a value for the attribute with the specified key. This API uses a promise t
| -------- | -------- |
| Promise<void> | Promise used to return the execution result.|
> **NOTE**
>
> - This API can be used only for setting parameters of system applications.
> - SELinux and discretionary access control (DAC) rules must be configured for authorized system applications. For details, see [Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
> - 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.
> - The APIs provided by this module are system APIs.
> - Third-party applications cannot use the APIs provided by this module, because system parameters each require specific discretionary access control (DAC) and MAC permissions.
| key | string | Yes| Key of the system parameter.|
| def | string | No| Default value.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Value of the system parameter. If the specified key does not exist, the default value is returned. If no default value has been set, an empty string will be returned.|