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
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
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>**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>**0**: Display color inversion is disabled.                                                       |
65
66## general
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
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
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
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
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
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
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 (for system apps only)
212
213**Parameters**
214
215| Name  | Type                   | Mandatory| Description                                                        |
216| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
217| context  | Context                 | Yes  | Application context.<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 (for system apps only)
245
246**Parameters**
247
248| Name | Type   | Mandatory| Description                                                        |
249| ------- | ------- | ---- | ------------------------------------------------------------ |
250| context | Context | Yes  | Application context.<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## setting.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**: ohos.permission.MANAGE_SECURE_SETTINGS (for system apps only)
283
284**Parameters**
285
286| Name  | Type                  | Mandatory| Description                                                                                                                                                                                                                                                                 |
287| -------- | ---------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
288| context  | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).                                                                                                                                                               |
289| 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                                                                                                                                                                                                     |
290| value    | string                 | Yes  | Value of the data item. The value range varies by service.                                                                                                                                                                                                                                                    |
291|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).|
292
293**Return value**
294
295| Type            | Description                               |
296| ---------------- | ----------------------------------- |
297| Promise\<string> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
298
299**Example**
300
301```js
302import settings from '@ohos.settings';
303
304// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
305const context: Context =  getContext(this);
306settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED).then((status) => {
307  console.log(`callback:return whether value is set.`)
308});
309```
310
311## setting.getValue<sup>10+</sup>
312
313getValue(context: Context, name: string, callback: AsyncCallback\<string>): void
314
315Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
316
317**Model restriction**: This API can be used only in the stage model.
318
319**System capability**: SystemCapability.Applications.Settings.Core
320
321**Parameters**
322
323| Name  | Type                  | Mandatory| Description                                                        |
324| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
325| context  | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
326| 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|
327| callback | AsyncCallback\<string> | Yes  | Callback used to return the value of the data item.                            |
328
329**Example**
330
331```js
332import settings from '@ohos.settings';
333const context: Context =  getContext(this);
334settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
335  if (err) {
336    console.error(`Failed to get the setting. ${err.message} `);
337    return;
338  }
339  console.log(`callback:value -> ${JSON.stringify(value)}`)
340});
341```
342
343## setting.getValue<sup>10+</sup>
344
345getValue(context: Context, name: string): Promise\<string>
346
347Obtains the value of a data item in the database. This API uses a promise to return the result.
348
349**Model restriction**: This API can be used only in the stage model.
350
351**System capability**: SystemCapability.Applications.Settings.Core
352
353**Parameters**
354
355| Name | Type   | Mandatory| Description                                                        |
356| ------- | ------- | ---- | ------------------------------------------------------------ |
357| context | Context | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
358| 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|
359
360**Return value**
361
362| Type            | Description                               |
363| ---------------- | ----------------------------------- |
364| Promise\<string> | Promise used to return the result. return the value of the data item.|
365
366**Example**
367
368```js
369import settings from '@ohos.settings';
370const context: Context =  getContext(this);
371settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
372  console.log(`promise:value -> ${JSON.stringify(value)}`)
373});
374```
375
376## settings.getValue<sup>11+</sup>
377
378getValue(context: Context, name: string, domainName: string): Promise\<string>;
379
380Obtains the value of a data item in the database. This API uses a promise to return the result.
381
382**Model restriction**: This API can be used only in the stage model.
383
384**System capability**: SystemCapability.Applications.Settings.Core
385
386**Parameters**
387
388| Name  | Type                  | Mandatory| Description                                                        |
389| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
390| context  | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
391| 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|
392|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).|
393
394**Return value**
395
396| Type            | Description                               |
397| ---------------- | ----------------------------------- |
398| Promise\<string> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
399
400**Example**
401
402```js
403import settings from '@ohos.settings';
404
405// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the getValue API will update its value.)
406const context: Context =  getContext(this);
407settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED).then((value) => {
408  console.log(`Promise:value -> $ {JSON.stringify(value)}`);
409});
410```
411
412## settings.getValueSync<sup>10+</sup>
413
414getValueSync(context: Context, name: string, defValue: string): string;
415
416Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
417
418**Model restriction**: This API can be used only in the stage model.
419
420**System capability**: SystemCapability.Applications.Settings.Core
421
422**Parameters**
423
424| Name  | Type   | Mandatory| Description                                                        |
425| -------- | ------- | ---- | ------------------------------------------------------------ |
426| context  | Context | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
427| 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|
428| 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.|
429
430**Return value**
431
432| Type  | Description            |
433| ------ | ---------------- |
434| string | Value of the data item.|
435
436**Example**
437
438```js
439import settings from '@ohos.settings';
440
441// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
442const context: Context =  getContext(this);
443let value = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
444```
445
446## settings.getValueSync<sup>11+</sup>
447
448getValueSync(context: Context, name: string, defValue: string, domainName: string): string;
449
450Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
451
452**Model restriction**: This API can be used only in the stage model.
453
454**System capability**: SystemCapability.Applications.Settings.Core
455
456**Parameters**
457
458| Name       | Type                  | Mandatory| Description                                                        |
459|------------| ---------------------- | ---- | ------------------------------------------------------------ |
460| context    | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
461| 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|
462| defValue   | string                 | Yes  | Value of the data item. The value range varies by service.                  |
463| 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).|
464
465
466**Return value**
467
468| Type            | Description                               |
469| ---------------- | ----------------------------------- |
470| string           | Value of the data item.                      |
471
472**Example**
473
474```js
475import settings from '@ohos.settings';
476
477// Update the value of .SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
478const context: Context =  getContext(this);
479let value = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100',  settings.domainName.DEVICE_SHARED);
480```
481
482## settings.setValueSync<sup>10+</sup>
483
484setValueSync(context: Context, name: string, value: string): boolean
485
486Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
487
488If 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.
489
490**Model restriction**: This API can be used only in the stage model.
491
492**System capability**: SystemCapability.Applications.Settings.Core
493
494**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (for system apps only)
495
496**Parameters**
497
498| Name | Type   | Mandatory| Description                                                        |
499| ------- | ------- | ---- | ------------------------------------------------------------ |
500| context | Context | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
501| 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|
502| value   | string  | Yes  | Value of the data item. The value range varies by service.                      |
503
504**Return value**
505
506| Type   | Description                                                        |
507| ------- | ------------------------------------------------------------ |
508| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
509
510**Example**
511
512```js
513import settings from '@ohos.settings';
514
515// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync API will update its value.)
516const context: Context =  getContext(this);
517let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
518```
519
520## settings.setValueSync<sup>11+</sup>
521
522setValueSync(context: Context, name: string, value: string, domainName: string): boolean
523
524Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
525
526If 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.
527
528**Model restriction**: This API can be used only in the stage model.
529
530**System capability**: SystemCapability.Applications.Settings.Core
531
532**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (for system apps only)
533
534**Parameters**
535
536| Name    | Type                  | Mandatory| Description                                                        |
537|---------| ---------------------- | ---- | ------------------------------------------------------------ |
538| context | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
539| 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|
540| value   | string                 | Yes  | Value of the data item. The value range varies by service.                  |
541| 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).|
542
543**Return value**
544
545| Type            | Description                               |
546| ---------------- | ----------------------------------- |
547| boolean          | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
548
549**Example**
550
551```js
552import settings from '@ohos.settings';
553
554// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync API will update its value.)
555const context: Context =  getContext(this);
556let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED);
557```
558
559## settings.registerKeyObserver<sup>11+</sup>
560
561registerKeyObserver(context: Context, name: string, domainName: string, observer:AsyncCallback\<void>): boolean
562
563Registers 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.
564
565**Model restriction**: This API can be used only in the stage model.
566
567**System capability**: SystemCapability.Applications.Settings.Core
568
569**Parameters**
570
571| Name  | Type                  | Mandatory| Description                                                        |
572| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
573| context  | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
574| 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|
575|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).|
576|observer  |  AsyncCallback\<void>  | Yes  | Callback used to return the value of the data item.                  |
577
578**Return value**
579
580| Type            | Description                               |
581| ---------------- | ----------------------------------- |
582| boolean | Returns **true** if the registration is successful; returns **false** otherwise.|
583
584**Example**
585
586```js
587import settings from '@ohos.settings';
588
589const context: Context =  getContext(this);
590settings.registerKeyObserver(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED, () => {
591  let value:string = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
592  console.log(`Promise:value -> $ {value}`);
593});
594```
595
596## settings.unregisterKeyObserver<sup>11+</sup>
597
598unregisterKeyObserver(context: Context, name: string, domainName: string): boolean
599
600Unregisters the observer under the specified domain name. This API returns the result synchronously.
601
602**Model restriction**: This API can be used only in the stage model.
603
604**System capability**: SystemCapability.Applications.Settings.Core
605
606| Name  | Type                  | Mandatory| Description                                                        |
607| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
608| context  | Context                | Yes  | Application context.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).|
609| 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|
610| value    | string                 | Yes  | Value of the data item. The value range varies by service.                  |
611|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).|
612
613**Return value**
614
615| Type            | Description                               |
616| ---------------- | ----------------------------------- |
617| boolean | Returns **true** if the registration is successful; returns **false** otherwise.|
618
619**Example**
620
621```js
622import settings from '@ohos.settings';
623
624const context: Context =  getContext(this);
625let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS,  settings.domainName.DEVICE_SHARED);
626```
627
628## settings.enableAirplaneMode
629
630enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
631
632Enables or disables airplane mode. This API uses an asynchronous callback to return the result.
633
634This API is not supported currently.
635
636**System capability**: SystemCapability.Applications.Settings.Core
637
638**Parameters**
639
640| Name  | Type                | Mandatory| Description                                           |
641| -------- | -------------------- | ---- | ----------------------------------------------- |
642| enable   | boolean              | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
643| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.                                     |
644
645**Example**
646
647```js
648let isEnabled :boolean = true;
649settings.enableAirplaneMode(isEnabled, (err:Error) => {
650    if (err) {
651        console.log('Failed to enable AirplaneMode.');
652        return;
653    }
654    console.log('Return true if enable.');
655})
656```
657
658## settings.enableAirplaneMode
659
660enableAirplaneMode(enable: boolean): Promise\<void>
661
662Enables or disables airplane mode. This API uses a promise to return the result.
663
664This API is not supported currently.
665
666**System capability**: SystemCapability.Applications.Settings.Core
667
668**Parameters**
669
670| Name| Type   | Mandatory| Description                                           |
671| ------ | ------- | ---- | ----------------------------------------------- |
672| enable | boolean | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
673
674**Return value**
675
676| Type          | Description                     |
677| -------------- | ------------------------- |
678| Promise\<void> | Promise that returns no value.|
679
680**Example**
681
682```js
683let isEnabled :boolean = true;
684settings.enableAirplaneMode(isEnabled).then(() => {
685  console.log('Succeeded in enabling AirplaneMode.');
686}).catch((err:Error) => {
687  console.log(`Failed to enable AirplaneMode. Cause: ${err}`);
688})
689```
690
691## settings.canShowFloating
692
693canShowFloating(callback: AsyncCallback\<boolean>): void
694
695Checks whether the application can be displayed in a floating window. This API uses an asynchronous callback to return the result.
696
697**System capability**: SystemCapability.Applications.Settings.Core
698
699**Parameters**
700
701| Name  | Type                   | Mandatory| Description                                                        |
702| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
703| 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.|
704
705**Example**
706
707```js
708settings.canShowFloating((err:Error, status: boolean) => {
709  if (err) {
710    console.error(`Failed to Checks whether a specified application can show as float window ${err.message} `);
711    return;
712  }
713  console.log('Checks whether a specified application can show as float window.');
714});
715```
716
717## settings.canShowFloating
718
719canShowFloating(): Promise\<boolean>
720
721Checks whether the application can be displayed in a floating window. This API uses a promise to return the result.
722
723**System capability**: SystemCapability.Applications.Settings.Core
724
725**Return value**
726
727| Type             | Description                                                        |
728| ----------------- | ------------------------------------------------------------ |
729| Promise\<boolean> | Promise used to return the result.<br>Returns **true** if the application can be displayed in a floating window; returns **false** otherwise.|
730
731**Example**
732
733```js
734settings.canShowFloating().then((status:boolean) => {
735    console.log('Checks whether a specified application can show as float window.');
736});
737```
738
739## settings.getUriSync<sup>8+</sup>
740
741getUriSync(name: string): string
742
743Obtains the URI of a data item.
744
745**System capability**: SystemCapability.Applications.Settings.Core
746
747**Parameters**
748
749| Name| Type  | Mandatory| Description                                                        |
750| ------ | ------ | ---- | ------------------------------------------------------------ |
751| 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|
752
753**Return value**
754
755| Type  | Description         |
756| ------ | ------------- |
757| string | URI of the data item.|
758
759**Example**
760
761```js
762// Obtain the URI of a data item.
763let uriVar:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
764```
765
766## setting.getURI<sup>(deprecated)</sup>
767
768getURI(name: string, callback: AsyncCallback\<object>): void
769
770Obtains the URI of a data item. This API uses an asynchronous callback to return the result.
771
772> **NOTE**
773>
774> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
775
776**System capability**: SystemCapability.Applications.Settings.Core
777
778**Parameters**
779
780| Name  | Type                  | Mandatory| Description                                                        |
781| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
782| 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|
783| callback | AsyncCallback\<object> | Yes  | Callback used to return the result. Obtains the URI of a data item.                                 |
784
785**Example**
786
787```js
788settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri:string) => {
789    console.log(`callback:uri -> ${JSON.stringify(uri)}`)
790})
791```
792
793## setting.getURI<sup>(deprecated)</sup>
794
795getURI(name: string): Promise\<object>
796
797Obtains the URI of a data item. This API uses a promise to return the result.
798
799> **NOTE**
800>
801> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
802
803**System capability**: SystemCapability.Applications.Settings.Core
804
805**Parameters**
806
807| Name| Type  | Mandatory| Description                                                        |
808| ------ | ------ | ---- | ------------------------------------------------------------ |
809| 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|
810
811**Return value**
812
813| Type            | Description                                |
814| ---------------- | ------------------------------------ |
815| Promise\<object> | Promise used to return the result. return the URI of the data item.|
816
817**Example**
818
819```js
820settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri:string) => {
821    console.log(`promise:uri -> ${JSON.stringify(uri)}`)
822})
823```
824
825
826
827## setting.getValue<sup>(deprecated)</sup>
828
829getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
830
831Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
832
833> **NOTE**
834>
835> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settinggetvalue10) instead.
836
837**Model restriction**: This API can be used only in the FA model.
838
839**System capability**: SystemCapability.Applications.Settings.Core
840
841**Parameters**
842
843| Name           | Type                                                        | Mandatory| Description                                                        |
844| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
845| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
846| 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|
847| callback          | AsyncCallback\<object>                                       | Yes  | Callback used to return the value of the data item.                            |
848
849**Example**
850
851```js
852import featureAbility from '@ohos.ability.featureAbility';
853
854let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
855let helper = featureAbility.acquireDataAbilityHelper(uri);
856settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err:Error, value:string) => {
857    if (err) {
858        console.error(`Failed to get the setting. ${err.message} `);
859        return;
860    }
861    console.log(`callback:value -> ${JSON.stringify(value)}`)
862});
863```
864
865## setting.getValue<sup>(deprecated)</sup>
866
867getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
868
869Obtains the value of a data item in the database. This API uses a promise to return the result.
870
871> **NOTE**
872>
873> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settinggetvalue10-1) instead.
874
875**Model restriction**: This API can be used only in the FA model.
876
877**System capability**: SystemCapability.Applications.Settings.Core
878
879**Parameters**
880
881| Name           | Type                                                        | Mandatory| Description                                                        |
882| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
883| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
884| 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|
885
886**Return value**
887
888| Type            | Description                               |
889| ---------------- | ----------------------------------- |
890| Promise\<object> | Promise used to return the result. return the value of the data item.|
891
892**Example**
893
894```js
895import featureAbility from '@ohos.ability.featureAbility';
896
897let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
898let helper = featureAbility.acquireDataAbilityHelper(uri);
899settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value:string) => {
900    console.log(`promise:value -> ${JSON.stringify(value)}`)
901});
902```
903
904## settings.getValueSync<sup>(deprecated)</sup>
905
906getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string
907
908Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
909
910> **NOTE**
911>
912> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getValueSync()](#settingsgetvaluesync10) instead.
913
914**Model restriction**: This API can be used only in the FA model.
915
916**System capability**: SystemCapability.Applications.Settings.Core
917
918**Parameters**
919
920| Name           | Type                                                        | Mandatory| Description                                                        |
921| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
922| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
923| 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|
924| 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.|
925
926**Return value**
927
928| Type  | Description            |
929| ------ | ---------------- |
930| string | Value of the data item.|
931
932**Example**
933
934```js
935import featureAbility from '@ohos.ability.featureAbility';
936
937// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
938let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
939let helper = featureAbility.acquireDataAbilityHelper(uri);
940let value:string = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
941```
942
943## settings.setValueSync<sup>(deprecated)</sup>
944
945setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
946
947Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
948
949If 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.
950
951> **NOTE**
952>
953> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setValueSync()](#settingssetvaluesync10) instead.
954
955**Model restriction**: This API can be used only in the FA model.
956
957**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications)
958
959**System capability**: SystemCapability.Applications.Settings.Core
960
961**Parameters**
962
963| Name           | Type                                                        | Mandatory| Description                                                        |
964| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
965| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
966| 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|
967| value             | string                                                       | Yes  | Value of the data item. The value range varies by service.                      |
968
969**Return value**
970
971| Type   | Description                                                        |
972| ------- | ------------------------------------------------------------ |
973| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
974
975**Example**
976
977```js
978import featureAbility from '@ohos.ability.featureAbility';
979
980// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update its value.)
981let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
982let helper = featureAbility.acquireDataAbilityHelper(uri);
983let ret:string = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
984```
985