未验证 提交 1c852158 编写于 作者: O openharmony_ci 提交者: Gitee

!2235 2206 处理完成:js-apis-settings.md 刷新

Merge pull request !2235 from ester.zhou/TR-2206
# Settings # Settings
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -14,10 +14,6 @@ import settings from '@ohos.settings'; ...@@ -14,10 +14,6 @@ import settings from '@ohos.settings';
``` ```
## Required Permissions
None
## settings.getUriSync ## settings.getUriSync
...@@ -25,10 +21,12 @@ getUriSync(name: string): string ...@@ -25,10 +21,12 @@ getUriSync(name: string): string
Obtains the URI of a data item. Obtains the URI of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br><ul><li>Existing data items in the database, for example:<br></li><ul><li>Brightness: 'settings.screen.brightness' <br> </li> <li>Time format: 'settings.time.format' <br> </li></ul> <li>Custom data items</li></ul>| | name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
- Return value - Return value
| Type| Description| | Type| Description|
...@@ -48,11 +46,13 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin ...@@ -48,11 +46,13 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin
Obtains the value of a data item. Obtains the value of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.| | dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br><ul><li>Existing data items in the database, for example:<br></li><ul><li>Brightness: 'settings.screen.brightness' <br> </li> <li>Time format: 'settings.time.format' <br> </li></ul> <li>Custom data items</li></ul>| | name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.| | defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.|
- Return value - Return value
...@@ -63,7 +63,7 @@ Obtains the value of a data item. ...@@ -63,7 +63,7 @@ Obtains the value of a data item.
- Example - Example
``` ```
import featureAbility from '@ohos.featureAbility'; import featureAbility from '@ohos.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database). // Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
let brightness = 'settings.screen.brightness'; let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness); let uri = settings.getUriSync(brightness);
...@@ -79,13 +79,15 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): ...@@ -79,13 +79,15 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string):
Sets the value of a data item. Sets the value of a data item.
If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database.
To use this method, you must have the **ohos.permission.WRITE_SYSTEM_SETTING** permission. **Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING
**System capability**: SystemCapability.Applictaions.settings.Core
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.| | dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br><ul><li>Existing data items in the database, for example:<br></li><ul><li>Brightness: 'settings.screen.brightness' <br> </li> <li>Time format: 'settings.time.format' <br> </li></ul> <li>Custom data items</li></ul>| | name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| value | string | Yes| Value of the data item.| | value | string | Yes| Value of the data item.|
- Return value - Return value
...@@ -96,9 +98,9 @@ To use this method, you must have the **ohos.permission.WRITE_SYSTEM_SETTING** p ...@@ -96,9 +98,9 @@ To use this method, you must have the **ohos.permission.WRITE_SYSTEM_SETTING** p
- Example - Example
``` ```
import featureAbility from '@ohos.featureAbility'; import featureAbility from '@ohos.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync method // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
will update the value of the data item.) method will update the value of the data item.)
let brightness = 'settings.screen.brightness'; let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness); let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri); let helper = featureAbility.acquireDataAbilityHelper(uri);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册