1# @ohos.settings (Data Item Settings)
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>
9>  - If no value is obtained for the accessed data item, it indicates that the current system app does not add the value of the data item to the database.
10
11## Modules to Import
12
13```js
14import settings from '@ohos.settings';
15```
16## domainName
17
18Describes the domain name.
19
20### Attributes
21
22**System capability**: SystemCapability.Applications.Settings.Core
23
24| Name                         | Type  | Readable| Writable| Description                                                        |
25|-----------------------------| ------ | ---- | ---- | ------------------------------------------------------------ |
26| DEVICE_SHARED<sup>11+</sup> | string | Yes  | Yes  | Shared device domain.                                         |
27| USER_PROPERTY<sup>11+</sup> | string | Yes  | Yes  | User property domain.                                          |
28
29## date (Not Supported)
30
31Provides data items for setting the time and date formats.
32
33### Attributes
34
35**System capability**: SystemCapability.Applications.Settings.Core
36
37| Name               | Type  | Readable| Writable| Description                                                        |
38| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
39| DATE_FORMAT         | string | Yes  | Yes  | Date format.<br>The value can be **mm/dd/yyyy**, **dd/mm/yyyy**, or **yyyy/mm/dd**, where **mm** indicates the month, **dd** indicates the day, and **yyyy** indicates the year.|
40| TIME_FORMAT         | string | Yes  | Yes  | Time format.<br>**12**: 12-hour format.<br>**24**: 24-hour format.|
41| AUTO_GAIN_TIME      | string | Yes  | Yes  | Whether the date, time, and time zone are automatically obtained from the Network Identity and Time Zone (NITZ).<br>The value **true** means that the date, time, and time zone are automatically obtained from NITZ;<br>and **false** means the opposite.|
42| AUTO_GAIN_TIME_ZONE | string | Yes  | Yes  | Whether the time zone is automatically obtained from NITZ.<br>The value **true** means that the time zone is automatically obtained from NITZ;<br>and **false** means the opposite.|
43
44## display (Not Supported)
45
46Provides data items for setting the display effects.
47
48### Attributes
49
50**System capability**: SystemCapability.Applications.Settings.Core
51
52| Name                         | Type  | Readable| Writable| Description                                                                                                         |
53| ----------------------------- | ------ | ---- | ---- |-------------------------------------------------------------------------------------------------------------|
54| FONT_SCALE                    | string | Yes  | Yes  | Scale factor of the font. The value is a floating point number. (In the current version, only fixed values can be queried.)                                                                             |
55| SCREEN_BRIGHTNESS_STATUS      | string | Yes  | Yes  | Screen brightness. The value ranges from 0 to 255.                                                                                          |
56| AUTO_SCREEN_BRIGHTNESS        | string | Yes  | Yes  | Whether automatic screen brightness adjustment is enabled.<br>**AUTO_SCREEN_BRIGHTNESS_MODE**: Automatic screen brightness adjustment is enabled.<br><br>**MANUAL_SCREEN_BRIGHTNESS_MODE**: Automatic screen brightness adjustment is disabled.   |
57| AUTO_SCREEN_BRIGHTNESS_MODE   | number | Yes  | Yes  | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is enabled.                                                                       |
58| MANUAL_SCREEN_BRIGHTNESS_MODE | number | Yes  | Yes  | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is disabled.                                                                       |
59| SCREEN_OFF_TIMEOUT            | string | Yes  | Yes  | Waiting time for the device to enter the sleep state when not in use (unit: ms).                                                                             |
60| DEFAULT_SCREEN_ROTATION       | string | Yes  | Yes  | Rotation angle. This attribute is valid only when screen auto-rotation is disabled.<br>**0**: The screen rotates by 0 degrees.<br>**1**: The screen rotates by 90 degrees.<br>**2**: The screen rotates by 180 degrees.<br>**3**: The screen rotates by 270 degrees.|
61| ANIMATOR_DURATION_SCALE       | string | Yes  | Yes  | Scale factor for the animation duration. This affects the start delay and duration of all such animations.<br>If the value is **0**, the animation ends immediately. The default value is **1**.                                                 |
62| TRANSITION_ANIMATION_SCALE    | string | Yes  | Yes  | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled.                                                                               |
63| WINDOW_ANIMATION_SCALE        | string | Yes  | Yes  | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled.                                                                             |
64| DISPLAY_INVERSION_STATUS      | string | Yes  | Yes  | Whether display color inversion is enabled.<br>**1**: Display color inversion is enabled.<br><br>**0**: Display color inversion is disabled.                                                       |
65
66## general (Not Supported)
67
68Provides data items for setting the general information about the device.
69
70### Attributes
71
72**System capability**: SystemCapability.Applications.Settings.Core
73
74| Name                            | Type  | Readable| Writable| Description                                                        |
75| -------------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
76| SETUP_WIZARD_FINISHED            | string | Yes  | Yes  | Whether the startup wizard is running.<br>If the value is **0**, the startup wizard is not running.<br>If the value is not **0**, the startup wizard is running.|
77| END_BUTTON_ACTION                | string | Yes  | Yes  | Action after the call end button is pressed if the user is not in a call.<br>**0**: Nothing happens.<br>**1**: The home screen is displayed.<br>**2**: The device enters sleep mode and the screen is locked.<br>**3**: The home screen is displayed. If the focus is already on the home screen, the device will enter sleep mode.|
78| ACCELEROMETER_ROTATION_STATUS    | string | Yes  | Yes  | Whether the accelerometer is used to change screen orientation, that is, whether to enable auto-rotation.<br>**1**: The accelerometer is used.<br>**0**: The accelerometer is not used.|
79| DEVICE_PROVISION_STATUS          | string | Yes  | Yes  | Whether the device is preconfigured.<br>On a multi-user device with a single system user, the screen may be locked when the value is **true**. In addition, other features cannot be started on the system user unless they are marked to display on the lock screen.|
80| HDC_STATUS                       | string | Yes  | Yes  | Whether the hard disk controller (HDC) on the USB device is enabled.<br>**true**: HDC is enabled.<br>**false**: HDC is disabled.|
81| BOOT_COUNTING                    | string | Yes  | Yes  | Number of boot operations after the device is powered on.                                    |
82| CONTACT_METADATA_SYNC_STATUS     | string | Yes  | Yes  | Whether contacts metadata synchronization is enabled.<br>**true**: Contacts metadata synchronization is enabled.<br>**false**: Contacts metadata synchronization is disabled.|
83| DEVICE_NAME                      | string | Yes  | Yes  | Device name.                                                  |
84| USB_STORAGE_STATUS               | string | Yes  | Yes  | Whether USB mass storage is enabled.<br>**true**: USB mass storage is enabled.<br>**false**: USB mass storage is disabled.|
85| DEBUGGER_WAITING                 | string | Yes  | Yes  | Whether the device waits for the debugger when starting an application to debug.<br>**1**: The device waits for the debugger.<br>**0**: The device does not wait for the debugger. In this case, the application runs normally.|
86| DEBUG_APP_PACKAGE                | string | Yes  | Yes  | Bundle name of the application to be debugged.                             |
87| ACCESSIBILITY_STATUS             | string | Yes  | Yes  | Whether accessibility is enabled.<br>**1**: Accessibility is enabled.<br>**0**: Accessibility is disabled.|
88| ACTIVATED_ACCESSIBILITY_SERVICES | string | Yes  | Yes  | List of activated accessibility features.                                    |
89| GEOLOCATION_ORIGINS_ALLOWED      | string | Yes  | Yes  | Default geographic location that can be used by the browser. Multiple geographic locations are separated by spaces.      |
90| SKIP_USE_HINTS                   | string | Yes  | Yes  | Whether the application should attempt to skip all introductory hints at the first startup. This feature is intended for temporary or experienced users.<br>**1**: The application attempts to skip all introductory hints at the first startup.<br>**0**: The application does not skip all introductory hints at the first startup.|
91| TOUCH_EXPLORATION_STATUS         | string | Yes  | Yes  | Whether touch exploration is enabled.<br>**1**: Touch exploration is enabled.<br>**0**: Touch exploration is disabled.|
92
93## input (Not Supported)
94
95Provides data items for setting input methods.
96
97### Attributes
98
99**System capability**: SystemCapability.Applications.Settings.Core
100
101| Name                                | Type  | Readable| Writable| Description                                                        |
102| ------------------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
103| DEFAULT_INPUT_METHOD                 | string | Yes  | Yes  | Default input method and its ID.                                          |
104| ACTIVATED_INPUT_METHOD_SUB_MODE      | string | Yes  | Yes  | Type and ID of the default input method keyboard.                                  |
105| ACTIVATED_INPUT_METHODS              | string | Yes  | Yes  | List of activated input methods.<br>The list is a string that contains the IDs and keyboard types of activated input methods. The IDs are separated by colons (:), and keyboard types are separated by semicolons (;). An example format is **ima0:keyboardType0;keyboardType1;ima1:ima2:keyboardTypes0,** where **ima** indicates the ID of an input method, and **keyboardType** indicates the keyboard type.|
106| SELECTOR_VISIBILITY_FOR_INPUT_METHOD | string | Yes  | Yes  | Whether the input method selector is visible.<br>**1**: The input method selector is visible.<br>**0**: The input method selector is invisible.|
107| AUTO_CAPS_TEXT_INPUT                 | string | Yes  | Yes  | Whether automatic capitalization is enabled for the text editor.<br>**0**: Automatic capitalization is disabled.<br>**1**: Automatic capitalization is enabled.|
108| AUTO_PUNCTUATE_TEXT_INPUT            | string | Yes  | Yes  | Whether automatic punctuation is enabled for the text editor. Automatic punctuation enables the text editor to convert two spaces into a period (.) and a space.<br>**0**: Automatic punctuation is disabled.<br>**1**: Automatic punctuation is enabled.|
109| AUTO_REPLACE_TEXT_INPUT              | string | Yes  | Yes  | Whether autocorrect is enabled for the text editor. Autocorrect enables the text editor to correct typos.<br>**0**: Autocorrect is disabled.<br>**1**: Autocorrect is enabled |
110| SHOW_PASSWORD_TEXT_INPUT             | string | Yes  | Yes  | Whether password presentation is enabled in the text editor. Password presentation enables the text editor to show password characters when the user types them.<br>**0**: Password presentation is disabled.<br>**1**: Password presentation is enabled.|
111
112## network (Not Supported)
113
114Provides data items for setting network information.
115
116### Attributes
117
118**System capability**: SystemCapability.Applications.Settings.Core
119
120| Name                    | Type  | Readable| Writable| Description                                                        |
121| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
122| DATA_ROAMING_STATUS      | string | Yes  | Yes  | Whether data roaming is enabled.<br>**true**: Data roaming is enabled.<br>**false**: Data roaming is disabled.|
123| HTTP_PROXY_CFG           | string | Yes  | Yes  | Host name and port number of the global HTTP proxy. The host name and port number are separated by a colon (:).|
124| NETWORK_PREFERENCE_USAGE | string | Yes  | Yes  | User preferences for the network to use.                                  |
125
126## phone (Not Supported)
127
128Provides data items for setting the modes of answering incoming and outgoing calls.
129
130### Attributes
131
132**System capability**: SystemCapability.Applications.Settings.Core
133
134| Name              | Type  | Readable| Writable| Description                                                        |
135| ------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
136| RTT_CALLING_STATUS | string | Yes  | Yes  | Whether the real-time text (RTT) feature is enabled. If this feature is enabled, incoming and outgoing calls are answered as RTT calls when supported by the device and carrier.<br> **1**: RTT is enabled.<br> **0**: RTT is disabled.|
137
138## sound (Not Supported)
139
140Provides data items for setting the sound effects.
141
142### Attributes
143
144**System capability**: SystemCapability.Applications.Settings.Core
145
146| Name                        | Type  | Readable| Writable| Description                                                        |
147| ---------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
148| VIBRATE_WHILE_RINGING        | string | Yes  | Yes  | Whether the device vibrates when it is ringing for an incoming call. This attribute is applicable to the phone and settings applications and affects only the scenario where the device rings for an incoming call. It does not affect any other application or scenario.|
149| DEFAULT_ALARM_ALERT          | string | Yes  | Yes  | Storage area of the system default alarms and alerts.                                    |
150| DTMF_TONE_TYPE_WHILE_DIALING | string | Yes  | Yes  | Type of the dual tone multi-frequency (DTMF) tone played while dialing.<br>**0**: normal short tone.<br>**1**: long tone.|
151| DTMF_TONE_WHILE_DIALING      | string | Yes  | Yes  | Whether the DTMF tone is played when dialing.<br>**1**: DTMF tone is played when dialing.<br>**0**: DTMF tone is not played when dialing.|
152| AFFECTED_MODE_RINGER_STREAMS | string | Yes  | Yes  | Which audio streams are affected by changes on the ringing mode and Do Not Disturb (DND) mode. If you want a specific audio stream to be affected by changes of the ringing mode and DDN mode, set the corresponding bit to **1**.|
153| AFFECTED_MUTE_STREAMS        | string | Yes  | Yes  | Audio streams affected by the mute mode. If you want a specific audio stream to remain muted in mute mode, set the corresponding bit to **1**.|
154| DEFAULT_NOTIFICATION_SOUND   | string | Yes  | Yes  | Storage area of the system default notification tone.                                  |
155| DEFAULT_RINGTONE             | string | Yes  | Yes  | Storage area of the system default ringtone.                                    |
156| SOUND_EFFECTS_STATUS         | string | Yes  | Yes  | Whether the sound feature is available.<br>**0**: The feature is not available.<br>**1**: The feature is available.  |
157| VIBRATE_STATUS               | string | Yes  | Yes  | Whether the device vibrates for an event. This attribute is used inside the system.<br>**1**: The device vibrates for an event.<br>**0**: The device does not vibrate for an event.|
158| HAPTIC_FEEDBACK_STATUS       | string | Yes  | Yes  | Whether haptic feedback is enabled.<br>**true**: Haptic feedback is enabled.<br>**false**: Haptic feedback is disabled.|
159
160## TTS (Not Supported)
161
162Provides data items for setting text-to-speech (TTS) information.
163
164### Attributes
165
166**System capability**: SystemCapability.Applications.Settings.Core
167
168| Name               | Type  | Readable| Writable| Description                                                        |
169| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
170| DEFAULT_TTS_PITCH   | string | Yes  | Yes  | Default pitch of the TTS engine.<br>100 = 1x. If the value is set to **200**, the frequency is twice the normal sound frequency.|
171| DEFAULT_TTS_RATE    | string | Yes  | Yes  | Default voice rate of the TTS engine.<br>100 = 1x.                        |
172| DEFAULT_TTS_SYNTH   | string | Yes  | Yes  | Default TTS engine.                                               |
173| ENABLED_TTS_PLUGINS | string | Yes  | Yes  | List of activated plug-in packages used for TTS. Multiple plug-in packages are separated by spaces.          |
174
175
176## wireless (Not Supported)
177
178Provides data items for setting wireless network information.
179
180### Attributes
181
182**System capability**: SystemCapability.Applications.Settings.Core
183
184| Name                             | Type  | Readable| Writable| Description                                                        |
185| --------------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
186| BLUETOOTH_DISCOVER_ABILITY_STATUS | string | Yes  | Yes  | Whether the device can be discovered or connected by other devices through Bluetooth.<br>**0**: The device cannot be discovered or connected.<br>**1**: The device can be connected but cannot be discovered.<br>**2**: The device can be discovered and connected.|
187| BLUETOOTH_DISCOVER_TIMEOUT        | string | Yes  | Yes  | Duration for discovering a device through Bluetooth, in seconds.<br>After the duration expires, the device cannot be discovered through Bluetooth.|
188| AIRPLANE_MODE_RADIOS              | string | Yes  | Yes  | List of radio signals to be disabled when airplane mode is enabled.<br>Multiple radio signals are separated by commas (,). The list can include the following: **BLUETOOTH_RADIO**, **CELL_RADIO**, **NFC_RADIO**, and **WIFI_RADIO**.|
189| BLUETOOTH_RADIO                   | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that Bluetooth is disabled in airplane mode.|
190| CELL_RADIO                        | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that cellular radio is disabled in airplane mode.|
191| NFC_RADIO                         | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that NFC is disabled in airplane mode.|
192| WIFI_RADIO                        | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that Wi-Fi is disabled in airplane mode.|
193| BLUETOOTH_STATUS                  | string | Yes  | Yes  | Whether Bluetooth is available.<br>**true**: Bluetooth is available.<br>**false**: Bluetooth is unavailable.|
194| OWNER_LOCKDOWN_WIFI_CFG           | string | Yes  | Yes  | Whether the Wi-Fi configuration created by the application of the device owner should be locked down.<br>**true**: The Wi-Fi configuration should be locked down.<br>**false**: The Wi-Fi configuration should not be locked down.|
195| WIFI_DHCP_MAX_RETRY_COUNT         | string | Yes  | Yes  | Maximum number of attempts to obtain an IP address from the DHCP server.                    |
196| WIFI_TO_MOBILE_DATA_AWAKE_TIMEOUT | string | Yes  | Yes  | Maximum duration to hold a wake lock when waiting for the mobile data connection to establish after the Wi-Fi connection is disconnected. |
197| WIFI_STATUS                       | string | Yes  | Yes  | Whether Wi-Fi is available.<br>**true**: Wi-Fi is available.<br>**false**: Wi-Fi is unavailable.|
198| WIFI_WATCHDOG_STATUS              | string | Yes  | Yes  | Whether Wi-Fi watchdog is available.<br>**true**: Wi-Fi watchdog is available.<br>**false**: Wi-Fi watchdog is unavailable.|
199
200
201## settings.setValue<sup>10+</sup>
202
203setValue(context: Context, name: string, value: string, callback: AsyncCallback\<boolean>): void
204
205Sets the value for a data item. This API uses an asynchronous callback to return the result.
206
207**Model restriction**: This API can be used only in the stage model.
208
209**System capability**: SystemCapability.Applications.Settings.Core
210
211**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications)
212
213**Parameters**
214
215| Name  | Type                   | Mandatory| Description                                                        |
216| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
217| context  | Context                 | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
218| 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|
219| value    | string                  | Yes  | Value of the data item. The value range varies by service.                              |
220| callback | AsyncCallback\<boolean> | Yes  | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.              |
221
222**Example**
223
224```js
225import settings from '@ohos.settings';
226
227// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
228const context: Context =  getContext(this);
229settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
230  console.log('Callback return whether value is set.');
231});
232```
233
234## settings.setValue<sup>10+</sup>
235
236setValue(context: Context, name: string, value: string): Promise\<boolean>
237
238Sets the value for a data item. This API uses a promise to return the result.
239
240**Model restriction**: This API can be used only in the stage model.
241
242**System capability**: SystemCapability.Applications.Settings.Core
243
244**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications)
245
246**Parameters**
247
248| Name | Type   | Mandatory| Description                                                        |
249| ------- | ------- | ---- | ------------------------------------------------------------ |
250| context | Context | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
251| 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|
252| value   | string  | Yes  | Value of the data item. The value range varies by service.                              |
253
254**Return value**
255
256| Type             | Description                                              |
257| ----------------- | -------------------------------------------------- |
258| Promise\<boolean> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
259
260**Example**
261
262```js
263import settings from '@ohos.settings';
264
265// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
266const context: Context =  getContext(this);
267settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
268  console.log('Callback return whether value is set.');
269});
270```
271
272## settings.setValue<sup>11+</sup>
273
274setValue(context: Context, name: string, value: string, domainName: string): Promise\<boolean>
275
276Sets the value for a data item. This API uses a promise to return the result.
277
278**Model restriction**: This API can be used only in the stage model.
279
280**System capability**: SystemCapability.Applications.Settings.Core
281
282**Required permissions**:
283
284ohos.permission.MANAGE_SETTINGS for writing the DEVICE_SHARED and USER_PROPERTY fields (available only to system applications);
285
286ohos.permission.MANAGE_SECURE_SETTINGS for writing the USER_SECURITY field (available only to system applications)
287
288**Parameters**
289
290| Name  | Type                  | Mandatory| Description                                                                                                                                                                                                                                                                 |
291| -------- | ---------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
292| context  | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).                                                                                                                                                               |
293| 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                                                                                                                                                                                                     |
294| value    | string                 | Yes  | Value of the data item. The value range varies by service.                                                                                                                                                                                                                                                    |
295|domainName| string                 | Yes  | Domain name to set.<br> - **domainName.DEVICE_SHARED**:<br>shared device domain<br>- **domainName.USER_PROPRERTY**:<br>user property domain<br> - **domainName.USER_SECURITY**:<br>&nbsp;&nbsp;&nbsp;Indicates the user security attribute domain (for system applications only).|
296
297**Return value**
298
299| Type            | Description                               |
300| ---------------- | ----------------------------------- |
301| Promise\<string> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
302
303**Example**
304
305```js
306import settings from '@ohos.settings';
307
308// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
309const context: Context =  getContext(this);
310settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED).then((status) => {
311  console.log(`callback:return whether value is set.`)
312});
313```
314
315## settings.getValue<sup>10+</sup>
316
317getValue(context: Context, name: string, callback: AsyncCallback\<string>): void
318
319Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
320
321**Model restriction**: This API can be used only in the stage model.
322
323**System capability**: SystemCapability.Applications.Settings.Core
324
325**Parameters**
326
327| Name  | Type                  | Mandatory| Description                                                        |
328| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
329| context  | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
330| 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|
331| callback | AsyncCallback\<string> | Yes  | Callback used to return the value of the data item.                            |
332
333**Example**
334
335```js
336import settings from '@ohos.settings';
337const context: Context =  getContext(this);
338settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
339  if (err) {
340    console.error(`Failed to get the setting. ${err.message} `);
341    return;
342  }
343  console.log(`callback:value -> ${JSON.stringify(value)}`)
344});
345```
346
347## settings.getValue<sup>10+</sup>
348
349getValue(context: Context, name: string): Promise\<string>
350
351Obtains the value of a data item in the database. This API uses a promise to return the result.
352
353**Model restriction**: This API can be used only in the stage model.
354
355**System capability**: SystemCapability.Applications.Settings.Core
356
357**Parameters**
358
359| Name | Type   | Mandatory| Description                                                        |
360| ------- | ------- | ---- | ------------------------------------------------------------ |
361| context | Context | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
362| 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|
363
364**Return value**
365
366| Type            | Description                               |
367| ---------------- | ----------------------------------- |
368| Promise\<string> | Promise used to return the result. return the value of the data item.|
369
370**Example**
371
372```js
373import settings from '@ohos.settings';
374const context: Context =  getContext(this);
375settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
376  console.log(`promise:value -> ${JSON.stringify(value)}`)
377});
378```
379
380## settings.getValue<sup>11+</sup>
381
382getValue(context: Context, name: string, domainName: string): Promise\<string>;
383
384Obtains the value of a data item in the database. This API uses a promise to return the result.
385
386**Model restriction**: This API can be used only in the stage model.
387
388**System capability**: SystemCapability.Applications.Settings.Core
389
390**Required permissions**:
391
392ohos.permission.MANAGE_SECURE_SETTINGS for reading the USER_SECURITY field (available only to system applications)
393
394**Parameters**
395
396| Name  | Type                  | Mandatory| Description                                                        |
397| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
398| context  | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
399| 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|
400|domainName| string                 | Yes  | Domain name to set.<br> - **domainName.DEVICE_SHARED**:<br>shared device domain<br>- **domainName.USER_PROPRERTY**:<br>user property domain<br> - **domainName.USER_SECURITY**:<br>&nbsp;&nbsp;&nbsp;Indicates the user security attribute domain (for system applications only).|
401
402**Return value**
403
404| Type            | Description                               |
405| ---------------- | ----------------------------------- |
406| Promise\<string> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
407
408**Example**
409
410```js
411import settings from '@ohos.settings';
412
413// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the getValue API will update its value.)
414const context: Context =  getContext(this);
415settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED).then((value) => {
416  console.log(`Promise:value -> $ {JSON.stringify(value)}`);
417});
418```
419
420## settings.getValueSync<sup>10+</sup>
421
422getValueSync(context: Context, name: string, defValue: string): string;
423
424Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
425
426**Model restriction**: This API can be used only in the stage model.
427
428**System capability**: SystemCapability.Applications.Settings.Core
429
430**Parameters**
431
432| Name  | Type   | Mandatory| Description                                                        |
433| -------- | ------- | ---- | ------------------------------------------------------------ |
434| context  | Context | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
435| 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|
436| defValue | string  | Yes  | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed.|
437
438**Return value**
439
440| Type  | Description            |
441| ------ | ---------------- |
442| string | Value of the data item.|
443
444**Example**
445
446```js
447import settings from '@ohos.settings';
448
449// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
450const context: Context =  getContext(this);
451let value = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
452```
453
454## settings.getValueSync<sup>11+</sup>
455
456getValueSync(context: Context, name: string, defValue: string, domainName: string): string;
457
458Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
459
460**Model restriction**: This API can be used only in the stage model.
461
462**System capability**: SystemCapability.Applications.Settings.Core
463
464**Required permissions**:
465
466ohos.permission.MANAGE_SECURE_SETTINGS for reading the USER_SECURITY field (available only to system applications)
467
468**Parameters**
469
470| Name       | Type                  | Mandatory| Description                                                        |
471|------------| ---------------------- | ---- | ------------------------------------------------------------ |
472| context    | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
473| 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|
474| defValue   | string                 | Yes  | Value of the data item. The value range varies by service.                  |
475| domainName | string                 | Yes  | Domain name to set.<br> - **domainName.DEVICE_SHARED**:<br>shared device domain<br>- **domainName.USER_PROPRERTY**:<br>user property domain<br> - **domainName.USER_SECURITY**:<br>&nbsp;&nbsp;&nbsp;Indicates the user security attribute domain (for system applications only).|
476
477
478**Return value**
479
480| Type            | Description                               |
481| ---------------- | ----------------------------------- |
482| string           | Value of the data item.                      |
483
484**Example**
485
486```js
487import settings from '@ohos.settings';
488
489// Update the value of .SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
490const context: Context =  getContext(this);
491let value = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100',  settings.domainName.DEVICE_SHARED);
492```
493
494## settings.setValueSync<sup>10+</sup>
495
496setValueSync(context: Context, name: string, value: string): boolean
497
498Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
499
500If 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.
501
502**Model restriction**: This API can be used only in the stage model.
503
504**System capability**: SystemCapability.Applications.Settings.Core
505
506**Required permissions**: ohos.permission.MANAGE_SETTINGS (available only to system applications)
507
508**Parameters**
509
510| Name | Type   | Mandatory| Description                                                        |
511| ------- | ------- | ---- | ------------------------------------------------------------ |
512| context | Context | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
513| 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|
514| value   | string  | Yes  | Value of the data item. The value range varies by service.                      |
515
516**Return value**
517
518| Type   | Description                                                        |
519| ------- | ------------------------------------------------------------ |
520| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
521
522**Example**
523
524```js
525import settings from '@ohos.settings';
526
527// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync API will update its value.)
528const context: Context =  getContext(this);
529let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
530```
531
532## settings.setValueSync<sup>11+</sup>
533
534setValueSync(context: Context, name: string, value: string, domainName: string): boolean
535
536Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
537
538If 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.
539
540**Model restriction**: This API can be used only in the stage model.
541
542**System capability**: SystemCapability.Applications.Settings.Core
543
544**Required permissions**:
545
546ohos.permission.MANAGE_SETTINGS for writing the DEVICE_SHARED and USER_PROPERTY fields (available only to system applications);
547
548ohos.permission.MANAGE_SECURE_SETTINGS for writing the USER_SECURITY field (available only to system applications)
549
550**Parameters**
551
552| Name    | Type                  | Mandatory| Description                                                        |
553|---------| ---------------------- | ---- | ------------------------------------------------------------ |
554| context | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
555| 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|
556| value   | string                 | Yes  | Value of the data item. The value range varies by service.                  |
557| domainName | string                 | Yes  | Domain name to set.<br> - **domainName.DEVICE_SHARED**:<br>shared device domain<br>- **domainName.USER_PROPRERTY**:<br>user property domain<br> - **domainName.USER_SECURITY**:<br>&nbsp;&nbsp;&nbsp;Indicates the user security attribute domain (for system applications only).|
558
559**Return value**
560
561| Type            | Description                               |
562| ---------------- | ----------------------------------- |
563| boolean          | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
564
565**Example**
566
567```js
568import settings from '@ohos.settings';
569
570// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync API will update its value.)
571const context: Context =  getContext(this);
572let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED);
573```
574
575## settings.registerKeyObserver<sup>11+</sup>
576
577registerKeyObserver(context: Context, name: string, domainName: string, observer:AsyncCallback\<void>): boolean
578
579Registers an observer in the specified context so that the specified data item can be observed in the specified domain name. When the data item value changes, the registered callback is called. If the registration is successful, **true** is returned. Otherwise, **false** is returned.
580
581**Model restriction**: This API can be used only in the stage model.
582
583**System capability**: SystemCapability.Applications.Settings.Core
584
585**Parameters**
586
587| Name  | Type                  | Mandatory| Description                                                        |
588| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
589| context  | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
590| 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|
591|domainName| string                 | Yes  | Domain name to set.<br> - **domainName.DEVICE_SHARED**:<br>shared device domain<br>- **domainName.USER_PROPRERTY**:<br>user property domain<br> - **domainName.USER_SECURITY**:<br>&nbsp;&nbsp;&nbsp;Indicates the user security attribute domain (for system applications only).|
592|observer  |  AsyncCallback\<void>  | Yes  | Callback used to return the value of the data item.                  |
593
594**Return value**
595
596| Type            | Description                               |
597| ---------------- | ----------------------------------- |
598| boolean | Returns **true** if the registration is successful; returns **false** otherwise.|
599
600**Example**
601
602```js
603import settings from '@ohos.settings';
604
605const context: Context =  getContext(this);
606settings.registerKeyObserver(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED, (err, val) => {
607  if (err) {
608    console.error(`Failed to get the setting. ${err.message} `);
609    return;
610  }
611  console.log(`callback:value -> ${JSON.stringify(val)}`)
612  let value:string = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
613  console.log(`Promise:value -> ${value}`);
614});
615```
616
617## settings.unregisterKeyObserver<sup>11+</sup>
618
619unregisterKeyObserver(context: Context, name: string, domainName: string): boolean
620
621Unregisters the observer under the specified domain name. This API returns the result synchronously.
622
623**Model restriction**: This API can be used only in the stage model.
624
625**System capability**: SystemCapability.Applications.Settings.Core
626
627| Name  | Type                  | Mandatory| Description                                                        |
628| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
629| context  | Context                | Yes  | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
630| 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|
631| value    | string                 | Yes  | Value of the data item. The value range varies by service.                  |
632|domainName| string                 | Yes  | Domain name to set.<br> - **domainName.DEVICE_SHARED**:<br>shared device domain<br>- **domainName.USER_PROPRERTY**:<br>user property domain<br> - **domainName.USER_SECURITY**:<br>&nbsp;&nbsp;&nbsp;Indicates the user security attribute domain (for system applications only).|
633
634**Return value**
635
636| Type            | Description                               |
637| ---------------- | ----------------------------------- |
638| boolean | Returns **true** if the registration is successful; returns **false** otherwise.|
639
640**Example**
641
642```js
643import settings from '@ohos.settings';
644
645const context: Context =  getContext(this);
646let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS,  settings.domainName.DEVICE_SHARED);
647```
648
649## settings.enableAirplaneMode (Not Supported)
650
651enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
652
653Enables or disables airplane mode. This API uses an asynchronous callback to return the result.
654
655This API is not supported currently.
656
657**System capability**: SystemCapability.Applications.Settings.Core
658
659**Parameters**
660
661| Name  | Type                | Mandatory| Description                                           |
662| -------- | -------------------- | ---- | ----------------------------------------------- |
663| enable   | boolean              | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
664| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.                                     |
665
666**Example**
667
668```js
669let isEnabled :boolean = true;
670settings.enableAirplaneMode(isEnabled, (err:Error) => {
671    if (err) {
672        console.log('Failed to enable AirplaneMode.');
673        return;
674    }
675    console.log('Return true if enable.');
676})
677```
678
679## settings.enableAirplaneMode (Not Supported)
680
681enableAirplaneMode(enable: boolean): Promise\<void>
682
683Enables or disables airplane mode. This API uses a promise to return the result.
684
685This API is not supported currently.
686
687**System capability**: SystemCapability.Applications.Settings.Core
688
689**Parameters**
690
691| Name| Type   | Mandatory| Description                                           |
692| ------ | ------- | ---- | ----------------------------------------------- |
693| enable | boolean | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
694
695**Return value**
696
697| Type          | Description                     |
698| -------------- | ------------------------- |
699| Promise\<void> | Promise that returns no value.|
700
701**Example**
702
703```js
704let isEnabled :boolean = true;
705settings.enableAirplaneMode(isEnabled).then(() => {
706  console.log('Succeeded in enabling AirplaneMode.');
707}).catch((err:Error) => {
708  console.log(`Failed to enable AirplaneMode. Cause: ${err}`);
709})
710```
711
712## settings.canShowFloating (Not Supported)
713
714canShowFloating(callback: AsyncCallback\<boolean>): void
715
716Checks whether the application can be displayed in a floating window. This API uses an asynchronous callback to return the result.
717
718**System capability**: SystemCapability.Applications.Settings.Core
719
720**Parameters**
721
722| Name  | Type                   | Mandatory| Description                                                        |
723| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
724| callback | AsyncCallback\<boolean> | Yes  | Callback used to return the result.<br>Returns **true** if the application can be displayed in a floating window; returns **false** otherwise.|
725
726**Example**
727
728```js
729settings.canShowFloating((err:Error, status: boolean) => {
730  if (err) {
731    console.error(`Failed to Checks whether a specified application can show as float window ${err.message} `);
732    return;
733  }
734  console.log('Checks whether a specified application can show as float window.');
735});
736```
737
738## settings.canShowFloating (Not Supported)
739
740canShowFloating(): Promise\<boolean>
741
742Checks whether the application can be displayed in a floating window. This API uses a promise to return the result.
743
744**System capability**: SystemCapability.Applications.Settings.Core
745
746**Return value**
747
748| Type             | Description                                                        |
749| ----------------- | ------------------------------------------------------------ |
750| Promise\<boolean> | Promise used to return the result.<br>Returns **true** if the application can be displayed in a floating window; returns **false** otherwise.|
751
752**Example**
753
754```js
755settings.canShowFloating().then((status:boolean) => {
756    console.log('Checks whether a specified application can show as float window.');
757});
758```
759
760## settings.getUriSync<sup>8+</sup> (Not Supported)
761
762getUriSync(name: string): string
763
764Obtains the URI of a data item.
765
766**System capability**: SystemCapability.Applications.Settings.Core
767
768**Parameters**
769
770| Name| Type  | Mandatory| Description                                                        |
771| ------ | ------ | ---- | ------------------------------------------------------------ |
772| 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|
773
774**Return value**
775
776| Type  | Description         |
777| ------ | ------------- |
778| string | URI of the data item.|
779
780**Example**
781
782```js
783// Obtain the URI of a data item.
784let uriVar:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
785```
786
787## settings.getURI<sup>(deprecated)</sup> (Not Supported)
788
789getURI(name: string, callback: AsyncCallback\<object>): void
790
791Obtains the URI of a data item. This API uses an asynchronous callback to return the result.
792
793> **NOTE**
794>
795> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
796
797**System capability**: SystemCapability.Applications.Settings.Core
798
799**Parameters**
800
801| Name  | Type                  | Mandatory| Description                                                        |
802| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
803| 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|
804| callback | AsyncCallback\<object> | Yes  | Callback used to return the result. Obtains the URI of a data item.                                 |
805
806**Example**
807
808```js
809settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri:string) => {
810    console.log(`callback:uri -> ${JSON.stringify(uri)}`)
811})
812```
813
814## settings.getURI<sup>(deprecated)</sup> (Not Supported)
815
816getURI(name: string): Promise\<object>
817
818Obtains the URI of a data item. This API uses a promise to return the result.
819
820> **NOTE**
821>
822> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
823
824**System capability**: SystemCapability.Applications.Settings.Core
825
826**Parameters**
827
828| Name| Type  | Mandatory| Description                                                        |
829| ------ | ------ | ---- | ------------------------------------------------------------ |
830| 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|
831
832**Return value**
833
834| Type            | Description                                |
835| ---------------- | ------------------------------------ |
836| Promise\<object> | Promise used to return the result. return the URI of the data item.|
837
838**Example**
839
840```js
841settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri:string) => {
842    console.log(`promise:uri -> ${JSON.stringify(uri)}`)
843})
844```
845
846
847
848## settings.getValue<sup>(deprecated)</sup>
849
850getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
851
852Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
853
854> **NOTE**
855>
856> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settingsgetvalue10) instead.
857
858**Model restriction**: This API can be used only in the FA model.
859
860**System capability**: SystemCapability.Applications.Settings.Core
861
862**Parameters**
863
864| Name           | Type                                                        | Mandatory| Description                                                        |
865| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
866| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
867| 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|
868| callback          | AsyncCallback\<object>                                       | Yes  | Callback used to return the value of the data item.                            |
869
870**Example**
871
872```js
873import featureAbility from '@ohos.ability.featureAbility';
874
875let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
876let helper = featureAbility.acquireDataAbilityHelper(uri);
877settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err:Error, value:string) => {
878    if (err) {
879        console.error(`Failed to get the setting. ${err.message} `);
880        return;
881    }
882    console.log(`callback:value -> ${JSON.stringify(value)}`)
883});
884```
885
886## settings.getValue<sup>(deprecated)</sup>
887
888getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
889
890Obtains the value of a data item in the database. This API uses a promise to return the result.
891
892> **NOTE**
893>
894> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settingsgetvalue10-1) instead.
895
896**Model restriction**: This API can be used only in the FA model.
897
898**System capability**: SystemCapability.Applications.Settings.Core
899
900**Parameters**
901
902| Name           | Type                                                        | Mandatory| Description                                                        |
903| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
904| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
905| 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|
906
907**Return value**
908
909| Type            | Description                               |
910| ---------------- | ----------------------------------- |
911| Promise\<object> | Promise used to return the result. return the value of the data item.|
912
913**Example**
914
915```js
916import featureAbility from '@ohos.ability.featureAbility';
917
918let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
919let helper = featureAbility.acquireDataAbilityHelper(uri);
920settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value:string) => {
921    console.log(`promise:value -> ${JSON.stringify(value)}`)
922});
923```
924
925## settings.getValueSync<sup>(deprecated)</sup>
926
927getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string
928
929Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
930
931> **NOTE**
932>
933> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getValueSync()](#settingsgetvaluesync10) instead.
934
935**Model restriction**: This API can be used only in the FA model.
936
937**System capability**: SystemCapability.Applications.Settings.Core
938
939**Parameters**
940
941| Name           | Type                                                        | Mandatory| Description                                                        |
942| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
943| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
944| 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|
945| defValue          | string                                                       | Yes  | Default value, which is returned when the value of a data item is not found in the database. Set this parameter as needed.|
946
947**Return value**
948
949| Type  | Description            |
950| ------ | ---------------- |
951| string | Value of the data item.|
952
953**Example**
954
955```js
956import featureAbility from '@ohos.ability.featureAbility';
957
958// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
959let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
960let helper = featureAbility.acquireDataAbilityHelper(uri);
961let value:string = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
962```
963
964## settings.setValueSync<sup>(deprecated)</sup>
965
966setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
967
968Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
969
970If 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.
971
972> **NOTE**
973>
974> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setValueSync()](#settingssetvaluesync10) instead.
975
976**Model restriction**: This API can be used only in the FA model.
977
978**Required permissions**: ohos.permission.MANAGE_SETTINGS (available only to system applications)
979
980**System capability**: SystemCapability.Applications.Settings.Core
981
982**Parameters**
983
984| Name           | Type                                                        | Mandatory| Description                                                        |
985| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
986| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
987| 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|
988| value             | string                                                       | Yes  | Value of the data item. The value range varies by service.                      |
989
990**Return value**
991
992| Type   | Description                                                        |
993| ------- | ------------------------------------------------------------ |
994| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
995
996**Example**
997
998```js
999import featureAbility from '@ohos.ability.featureAbility';
1000
1001// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update its value.)
1002let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
1003let helper = featureAbility.acquireDataAbilityHelper(uri);
1004let ret:string = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
1005```
1006