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

!5203 翻译完成 4304:fix interface in js-apis-settings.md

Merge pull request !5203 from ester.zhou/TR-4305
# Settings # Settings
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> 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.
...@@ -23,21 +23,24 @@ Obtains the URI of a data item. ...@@ -23,21 +23,24 @@ Obtains the URI of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core **System capability**: SystemCapability.Applictaions.settings.Core
- Parameters **Parameters**
| 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>|
- Return value | Name| Type| Mandatory| Description|
| Type| 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>|
| string | URI of the data item.|
- Example **Return value**
```typescript
| Type| Description|
| -------- | -------- |
| string | URI of the data item.|
**Example**
```typescript
// Obtain the URI of a data item. // Obtain the URI of a data item.
let urivar = settings.getUriSync('settings.screen.brightness'); let urivar = settings.getUriSync('settings.screen.brightness');
``` ```
## settings.getValueSync ## settings.getValueSync
...@@ -48,28 +51,30 @@ Obtains the value of a data item. ...@@ -48,28 +51,30 @@ Obtains the value of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core **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 | Type| Description|
| Type| Description| | -------- | -------- |
| -------- | -------- | | string | Value of the data item.|
| string | Value of the data item.|
- Example **Example**
```typescript
```typescript
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.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);
let helper = featureAbility.acquireDataAbilityHelper(uri); let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, brightness, '10'); let value = settings.getValueSync(helper, brightness, '10');
``` ```
## settings.setValueSync ## settings.setValueSync
...@@ -77,32 +82,36 @@ Obtains the value of a data item. ...@@ -77,32 +82,36 @@ Obtains the value of a data item.
setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
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.
**Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING **Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING
**System capability**: SystemCapability.Applictaions.settings.Core **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.| | -------- | -------- | -------- | -------- |
| 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>| | dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| value | string | Yes| Value of the data item.| | 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.|
**Return value**
- Return value | Type| Description|
| Type| Description| | -------- | -------- |
| -------- | -------- | | boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
- Example **Example**
```typescript
```typescript
import featureAbility from '@ohos.ability.featureAbility'; 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.screen.brightness'. (As this data item exists in the database, the setValueSync
method 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);
let ret = settings.setValueSync(helper, brightness, '100'); let ret = settings.setValueSync(helper, brightness, '100');
``` ```
\ No newline at end of file
# System Parameter # System Parameter
> **NOTE**<br> > **NOTE**<br>
>
> - 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. > - 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. > - This is a system API and cannot be called by third-party applications.
...@@ -49,7 +48,7 @@ try { ...@@ -49,7 +48,7 @@ try {
get(key: string, callback: AsyncCallback&lt;string&gt;): void get(key: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the value of the attribute with the specified key. Obtains the value of the attribute with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SysInfo **System capability**: SystemCapability.Startup.SysInfo
...@@ -80,7 +79,7 @@ try { ...@@ -80,7 +79,7 @@ try {
get(key: string, def: string, callback: AsyncCallback&lt;string&gt;): void get(key: string, def: string, callback: AsyncCallback&lt;string&gt;): void
Obtains the value of the attribute with the specified key. Obtains the value of the attribute with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SysInfo **System capability**: SystemCapability.Startup.SysInfo
...@@ -89,7 +88,7 @@ Obtains the value of the attribute with the specified key. ...@@ -89,7 +88,7 @@ Obtains the value of the attribute with the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | Yes| Default Value| | def | string | Yes| Default value.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -113,7 +112,7 @@ try { ...@@ -113,7 +112,7 @@ try {
get(key: string, def?: string): Promise&lt;string&gt; get(key: string, def?: string): Promise&lt;string&gt;
Obtains the value of the attribute with the specified key. Obtains the value of the attribute with the specified key. This API uses a promise to return the result.
**System capability**: SystemCapability.Startup.SysInfo **System capability**: SystemCapability.Startup.SysInfo
...@@ -122,7 +121,7 @@ Obtains the value of the attribute with the specified key. ...@@ -122,7 +121,7 @@ Obtains the value of the attribute with the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | No| Default Value| | def | string | No| Default value.|
**Return value** **Return value**
...@@ -176,7 +175,7 @@ try { ...@@ -176,7 +175,7 @@ try {
set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
Sets a value for the attribute with the specified key. Sets a value for the attribute with the specified key. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Startup.SysInfo **System capability**: SystemCapability.Startup.SysInfo
...@@ -208,7 +207,7 @@ try { ...@@ -208,7 +207,7 @@ try {
set(key: string, value: string): Promise&lt;void&gt; set(key: string, value: string): Promise&lt;void&gt;
Sets a value for the attribute with the specified key. Sets a value for the attribute with the specified key. This API uses a promise to return the result.
**System capability**: SystemCapability.Startup.SysInfo **System capability**: SystemCapability.Startup.SysInfo
...@@ -217,7 +216,7 @@ Sets a value for the attribute with the specified key. ...@@ -217,7 +216,7 @@ Sets a value for the attribute with the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| value| string | Yes| System attribute value to set.| | value| string | Yes | System attribute value to set.|
**Return value** **Return value**
......
...@@ -36,7 +36,7 @@ Each application can subscribe to common events as required. After your applicat ...@@ -36,7 +36,7 @@ Each application can subscribe to common events as required. After your applicat
## How to Use ## How to Use
For details, see *CommonEvent Development Guidelines*. For details, see [Common Event Development](../application-dev/notification/common-event.md).
## Repositories Involved ## Repositories Involved
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册