• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.settings (Data Item Settings) (System API)
2
3The **settings** module provides APIs for setting data items.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8> - This topic describes only system APIs provided by the module. For details about its public APIs, see [@ohos.settings (Data Item Settings)](./js-apis-settings.md).
9
10## Modules to Import
11
12```js
13import settings from '@ohos.settings';
14```
15
16
17## settings.setValue<sup>(deprecated)</sup>
18
19setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback\<boolean>): void
20
21Sets the value for a data item. This API uses an asynchronous callback to return the result.
22
23> **NOTE**
24>
25> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setValue()](js-apis-settings.md#settingssetvalue10) instead.
26
27**System API**: This is a system API.
28
29**Model restriction**: This API can be used only in the FA model.
30
31**System capability**: SystemCapability.Applications.Settings.Core
32
33**Parameters**
34
35| Name           | Type                                                        | Mandatory| Description                                                        |
36| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
37| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
38| name              | string                                                       | Yes  | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
39| value             | object                                                       | Yes  | Value of the data item. The value range varies by service.                              |
40| callback          | AsyncCallback\<boolean>                                      | Yes  | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.              |
41
42
43## settings.setValue<sup>(deprecated)</sup>
44
45setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise\<boolean>
46
47Sets the value for a data item. This API uses a promise to return the result.
48
49> **NOTE**
50>
51> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [setValue()](js-apis-settings.md#settingssetvalue10-1) instead.
52
53**System API**: This is a system API.
54
55**Model restriction**: This API can be used only in the FA model.
56
57**System capability**: SystemCapability.Applications.Settings.Core
58
59**Parameters**
60
61| Name           | Type                                                        | Mandatory| Description                                                        |
62| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
63| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
64| name              | string                                                       | Yes  | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
65| value             | object                                                       | Yes  | Value of the data item. The value range varies by service.                              |
66
67**Return value**
68
69| Type             | Description                                              |
70| ----------------- | -------------------------------------------------- |
71| Promise\<boolean> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
72