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

!5497 fix const value in js-apis-settings.md

Merge pull request !5497 from 吕晓强/master
......@@ -27,7 +27,7 @@ Obtains the URI of a data item.
| 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.display.SCREEN_BRIGHTNESS_STATUS<br> </li> <li>Time format: settings.date.TIME_FORMAT<br> </li></ul> <li>Custom data items</li></ul>|
**Return value**
......@@ -39,7 +39,7 @@ Obtains the URI of a data item.
```typescript
// Obtain the URI of a data item.
let urivar = settings.getUriSync('settings.screen.brightness');
let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
```
......@@ -55,7 +55,7 @@ Obtains the value of a data item.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.display.SCREEN_BRIGHTNESS_STATUS<br> </li> <li>Time format: settings.date.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.|
**Return value**
......@@ -69,11 +69,10 @@ Obtains the value of a data item.
```typescript
import featureAbility from '@ohos.ability.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
// Obtain the value of settings.display.SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, brightness, '10');
let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
```
......@@ -85,7 +84,7 @@ 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.
**Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING
**Required permissions**: ohos.permission.MODIFY_SETTINGS
**System capability**: SystemCapability.Applictaions.settings.Core
......@@ -94,7 +93,7 @@ If the specified data item exists in the database, the **setValueSync** method u
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.display.SCREEN_BRIGHTNESS_STATUS<br> </li> <li>Time format: settings.date.TIME_FORMAT<br> </li></ul> <li>Custom data items</li></ul>|
| value | string | Yes| Value of the data item.|
**Return value**
......@@ -108,10 +107,9 @@ If the specified data item exists in the database, the **setValueSync** method u
```typescript
import featureAbility from '@ohos.ability.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
// Update the value of settings.display.SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync
method will update the value of the data item.)
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let ret = settings.setValueSync(helper, brightness, '100');
let ret = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
```
\ No newline at end of file
......@@ -26,7 +26,7 @@ getUriSync(name: string): string
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| name | string | 是 | 数据项的名称。数据项名称分为以下两种:<br> <ul><li>数据库中已存在的数据项,包括:<br></li> <ul><li>亮度:'settings.screen.brightness' <br> </li> <li> 时间格式:'settings.time.format' <br> </li></ul> <li>开发者自行添加的数据项。</li></ul>|
| name | string | 是 | 数据项的名称。数据项名称分为以下两种:<br> <ul><li>数据库中已存在的数据项,包括:<br></li> <ul><li>亮度:settings.display.SCREEN_BRIGHTNESS_STATUS <br> </li> <li> 时间格式:settings.date.TIME_FORMAT <br> </li></ul> <li>开发者自行添加的数据项。</li></ul>|
- 返回值:
| 类型 | 说明 |
......@@ -36,7 +36,7 @@ getUriSync(name: string): string
- 示例:
```typescript
// 获取数据项的URI
let urivar = settings.getUriSync('settings.screen.brightness');
let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
```
......@@ -52,7 +52,7 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | 是 | 数据管理辅助类。 |
| name | string | 是 | 数据项的名称。数据项名称分为以下两种:<br> <ul><li>数据库中已存在的数据项,包括:<br></li> <ul><li>亮度:'settings.screen.brightness' <br> </li> <li> 时间格式:'settings.time.format' <br> </li></ul> <li>开发者自行添加的数据项。</li></ul>|
| name | string | 是 | 数据项的名称。数据项名称分为以下两种:<br> <ul><li>数据库中已存在的数据项,包括:<br></li> <ul><li>亮度:settings.display.SCREEN_BRIGHTNESS_STATUS <br> </li> <li> 时间格式:settings.date.TIME_FORMAT <br> </li></ul> <li>开发者自行添加的数据项。</li></ul>|
| defValue | string | 是 | 默认值。由开发者设置,当未从数据库中查询到该数据时,则返回该默认值。 |
- 返回值:
......@@ -65,10 +65,9 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin
import featureAbility from '@ohos.ability.featureAbility';
//获取数据项亮度的值(该数据项在数据库中已存在)
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, brightness, '10');
let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
```
......@@ -79,7 +78,7 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string):
设置数据项的值。
如果数据库中已经存在该数据项,则setValueSync方法将更新该数据项的值;如果数据库中尚未存在该数据项,则setValueSync方法将向数据库中插入该数据项。
**需要权限**:ohos.permission.WRITE_SYSTEM_SETTING
**需要权限**:ohos.permission.MODIFY_SETTINGS
**系统能力**:SystemCapability.Applictaions.settings.Core。
......@@ -87,7 +86,7 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string):
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | 是 | 数据管理辅助类。 |
| name | string | 是 | 数据项的名称。数据项名称分为以下两种:<br> <ul><li>数据库中已存在的数据项,包括:<br></li> <ul><li>亮度:'settings.screen.brightness' <br> </li> <li> 时间格式:'settings.time.format' <br> </li></ul> <li>开发者自行添加的数据项。</li></ul>|
| name | string | 是 | 数据项的名称。数据项名称分为以下两种:<br> <ul><li>数据库中已存在的数据项,包括:<br></li> <ul><li>亮度:settings.display.SCREEN_BRIGHTNESS_STATUS <br> </li> <li> 时间格式:settings.date.TIME_FORMAT <br> </li></ul> <li>开发者自行添加的数据项。</li></ul>|
| value | string | 是 | 数据项的具体数值。 |
- 返回值:
......@@ -100,8 +99,7 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string):
import featureAbility from '@ohos.ability.featureAbility';
//更新数据项亮度的值(该数据项在数据库中已存在,故setValueSync方法将更新该数据项的值)
let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness);
let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
let helper = featureAbility.acquireDataAbilityHelper(uri);
let ret = settings.setValueSync(helper, brightness, '100');
let ret = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册