• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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## Modules to Import
10
11```js
12import settings from '@ohos.settings';
13```
14## domainName
15
16Describes the domain name.
17
18### Attributes
19
20**System capability**: SystemCapability.Applications.Settings.Core
21
22| Name               | Type  | Readable| Writable| Description                                                        |
23| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
24| DEVICE_SHARED       | string | Yes  | Yes  | Shared device domain.                                         |
25| USER_PROPERTY       | string | Yes  | Yes  | User property domain.                                          |
26| USER_SECURITY       | string | Yes  | Yes  | User security domain.                                       |
27
28## date
29
30Provides data items for setting the time and date formats.
31
32### Attributes
33
34**System capability**: SystemCapability.Applications.Settings.Core
35
36| Name               | Type  | Readable| Writable| Description                                                        |
37| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
38| 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.|
39| TIME_FORMAT         | string | Yes  | Yes  | Time format.<br>**12**: 12-hour format.<br>**24**: 24-hour format.|
40| 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.|
41| 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.|
42
43## display
44
45Provides data items for setting the display effects.
46
47### Attributes
48
49**System capability**: SystemCapability.Applications.Settings.Core
50
51| Name                         | Type  | Readable| Writable| Description                                                        |
52| ----------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
53| FONT_SCALE                    | string | Yes  | Yes  | Scale factor of the font. The value is a floating point number.                                |
54| SCREEN_BRIGHTNESS_STATUS      | string | Yes  | Yes  | Screen brightness. The value ranges from 0 to 255.                              |
55| 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.|
56| AUTO_SCREEN_BRIGHTNESS_MODE   | number | Yes  | Yes  | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is enabled.          |
57| MANUAL_SCREEN_BRIGHTNESS_MODE | number | Yes  | Yes  | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is disabled.          |
58| SCREEN_OFF_TIMEOUT            | string | Yes  | Yes  | Waiting time for the device to enter the sleep state when not in use (unit: ms).  |
59| 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.|
60| 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**.|
61| TRANSITION_ANIMATION_SCALE    | string | Yes  | Yes  | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled.          |
62| WINDOW_ANIMATION_SCALE        | string | Yes  | Yes  | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled.      |
63| 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.|
64
65## general
66
67Provides data items for setting the general information about the device.
68
69### Attributes
70
71**System capability**: SystemCapability.Applications.Settings.Core
72
73| Name                            | Type  | Readable| Writable| Description                                                        |
74| -------------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
75| 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.|
76| 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.|
77| 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.|
78| AIRPLANE_MODE_STATUS             | string | Yes  | Yes  | Whether airplane mode is enabled.<br>**1**: Airplane mode is enabled.<br>**0**: Airplane mode is disabled.|
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| DEVELOPMENT_SETTINGS_STATUS      | string | Yes  | Yes  | Whether developer options are enabled.<br>**true**: Developer options are enabled.<br>**false**: Developer options are disabled.|
84| DEVICE_NAME                      | string | Yes  | Yes  | Device name.                                                  |
85| 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.|
86| 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.|
87| DEBUG_APP_PACKAGE                | string | Yes  | Yes  | Bundle name of the application to be debugged.                             |
88| ACCESSIBILITY_STATUS             | string | Yes  | Yes  | Whether accessibility is enabled.<br>**1**: Accessibility is enabled.<br>**0**: Accessibility is disabled.|
89| ACTIVATED_ACCESSIBILITY_SERVICES | string | Yes  | Yes  | List of activated accessibility features.                                    |
90| GEOLOCATION_ORIGINS_ALLOWED      | string | Yes  | Yes  | Default geographic location that can be used by the browser. Multiple geographic locations are separated by spaces.      |
91| 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.|
92| TOUCH_EXPLORATION_STATUS         | string | Yes  | Yes  | Whether touch exploration is enabled.<br>**1**: Touch exploration is enabled.<br>**0**: Touch exploration is disabled.|
93
94## input
95
96Provides data items for setting input methods.
97
98### Attributes
99
100**System capability**: SystemCapability.Applications.Settings.Core
101
102| Name                                | Type  | Readable| Writable| Description                                                        |
103| ------------------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
104| DEFAULT_INPUT_METHOD                 | string | Yes  | Yes  | Default input method and its ID.                                          |
105| ACTIVATED_INPUT_METHOD_SUB_MODE      | string | Yes  | Yes  | Type and ID of the default input method keyboard.                                  |
106| 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.|
107| 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.|
108| 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.|
109| 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.|
110| 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 |
111| 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.|
112
113## network
114
115Provides data items for setting network information.
116
117### Attributes
118
119**System capability**: SystemCapability.Applications.Settings.Core
120
121| Name                    | Type  | Readable| Writable| Description                                                        |
122| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
123| DATA_ROAMING_STATUS      | string | Yes  | Yes  | Whether data roaming is enabled.<br>**true**: Data roaming is enabled.<br>**false**: Data roaming is disabled.|
124| 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 (:).|
125| NETWORK_PREFERENCE_USAGE | string | Yes  | Yes  | User preferences for the network to use.                                  |
126
127## phone
128
129Provides data items for setting the modes of answering incoming and outgoing calls.
130
131### Attributes
132
133**System capability**: SystemCapability.Applications.Settings.Core
134
135| Name              | Type  | Readable| Writable| Description                                                        |
136| ------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
137| 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.|
138
139## sound
140
141Provides data items for setting the sound effects.
142
143### Attributes
144
145**System capability**: SystemCapability.Applications.Settings.Core
146
147| Name                        | Type  | Readable| Writable| Description                                                        |
148| ---------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
149| 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.|
150| DEFAULT_ALARM_ALERT          | string | Yes  | Yes  | Storage area of the system default alarms and alerts.                                    |
151| 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.|
152| 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.|
153| 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**.|
154| 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**.|
155| DEFAULT_NOTIFICATION_SOUND   | string | Yes  | Yes  | Storage area of the system default notification tone.                                  |
156| DEFAULT_RINGTONE             | string | Yes  | Yes  | Storage area of the system default ringtone.                                    |
157| 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.  |
158| 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.|
159| HAPTIC_FEEDBACK_STATUS       | string | Yes  | Yes  | Whether haptic feedback is enabled.<br>**true**: Haptic feedback is enabled.<br>**false**: Haptic feedback is disabled.|
160
161## TTS
162
163Provides data items for setting text-to-speech (TTS) information.
164
165### Attributes
166
167**System capability**: SystemCapability.Applications.Settings.Core
168
169| Name               | Type  | Readable| Writable| Description                                                        |
170| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
171| 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.|
172| DEFAULT_TTS_RATE    | string | Yes  | Yes  | Default voice rate of the TTS engine.<br>100 = 1x.                        |
173| DEFAULT_TTS_SYNTH   | string | Yes  | Yes  | Default TTS engine.                                               |
174| ENABLED_TTS_PLUGINS | string | Yes  | Yes  | List of activated plug-in packages used for TTS. Multiple plug-in packages are separated by spaces.          |
175
176
177## wireless
178
179Provides data items for setting wireless network information.
180
181### Attributes
182
183**System capability**: SystemCapability.Applications.Settings.Core
184
185| Name                             | Type  | Readable| Writable| Description                                                        |
186| --------------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
187| 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.|
188| 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.|
189| 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**.|
190| BLUETOOTH_RADIO                   | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that Bluetooth is disabled in airplane mode.|
191| CELL_RADIO                        | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that cellular radio is disabled in airplane mode.|
192| NFC_RADIO                         | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that NFC is disabled in airplane mode.|
193| WIFI_RADIO                        | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that Wi-Fi is disabled in airplane mode.|
194| BLUETOOTH_STATUS                  | string | Yes  | Yes  | Whether Bluetooth is available.<br>**true**: Bluetooth is available.<br>**false**: Bluetooth is unavailable.|
195| 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.|
196| WIFI_DHCP_MAX_RETRY_COUNT         | string | Yes  | Yes  | Maximum number of attempts to obtain an IP address from the DHCP server.                    |
197| 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. |
198| WIFI_STATUS                       | string | Yes  | Yes  | Whether Wi-Fi is available.<br>**true**: Wi-Fi is available.<br>**false**: Wi-Fi is unavailable.|
199| 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.|
200
201
202## settings.setValue<sup>10+</sup>
203
204setValue(context: Context, name: string, value: string, callback: AsyncCallback\<boolean>): void
205
206Sets the value for a data item. This API uses an asynchronous callback to return the result.
207
208**Model restriction**: This API can be used only in the stage model.
209
210**System capability**: SystemCapability.Applications.Settings.Core
211
212**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
213
214**Parameters**
215
216| Name  | Type                   | Mandatory| Description                                                        |
217| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
218| 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).|
219| 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|
220| value    | string                  | Yes  | Value of the data item. The value range varies by service.                              |
221| callback | AsyncCallback\<boolean> | Yes  | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.              |
222
223**Example**
224
225```js
226import settings from '@ohos.settings';
227
228// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
229const context: Context =  getContext(this);
230settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
231  console.log('Callback return whether value is set.');
232});
233```
234
235## settings.setValue<sup>10+</sup>
236
237setValue(context: Context, name: string, value: string): Promise\<boolean>
238
239Sets the value for a data item. This API uses a promise to return the result.
240
241**Model restriction**: This API can be used only in the stage model.
242
243**System capability**: SystemCapability.Applications.Settings.Core
244
245**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
246
247**Parameters**
248
249| Name | Type   | Mandatory| Description                                                        |
250| ------- | ------- | ---- | ------------------------------------------------------------ |
251| 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).|
252| 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|
253| value   | string  | Yes  | Value of the data item. The value range varies by service.                              |
254
255**Return value**
256
257| Type             | Description                                              |
258| ----------------- | -------------------------------------------------- |
259| Promise\<boolean> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
260
261**Example**
262
263```js
264import settings from '@ohos.settings';
265
266// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
267const context: Context =  getContext(this);
268settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
269  console.log('Callback return whether value is set.');
270});
271```
272
273## setting.setValue<sup>11+</sup>
274
275setValue(context: Context, name: string, domainName: string): Promise\<boolean>
276
277Sets the value for a data item. This API uses a promise to return the result.
278
279**System capability**: SystemCapability.Applications.Settings.Core
280
281**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
282
283**Parameters**
284
285| Name  | Type                  | Mandatory| Description                                                        |
286| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
287| 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).|
288| 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|
289| value    | string                 | Yes  | Value of the data item. The value range varies by service.                  |
290|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>user security domain|
291
292**Return value**
293
294| Type            | Description                               |
295| ---------------- | ----------------------------------- |
296| Promise\<string> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
297
298**Example**
299
300```js
301import settings from '@ohos.settings';
302
303// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.)
304const context: Context =  getContext(this);
305settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED).then((status) => {
306  console.log(`callback:return whether value is set.`)
307});
308```
309
310## setting.getValue<sup>10+</sup>
311
312getValue(context: Context, name: string, callback: AsyncCallback\<string>): void
313
314Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
315
316**Model restriction**: This API can be used only in the stage model.
317
318**System capability**: SystemCapability.Applications.Settings.Core
319
320**Parameters**
321
322| Name  | Type                  | Mandatory| Description                                                        |
323| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
324| 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).|
325| 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|
326| callback | AsyncCallback\<string> | Yes  | Callback used to return the value of the data item.                            |
327
328**Example**
329
330```js
331import settings from '@ohos.settings';
332const context: Context =  getContext(this);
333settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
334  if (err) {
335    console.error(`Failed to get the setting. ${err.message} `);
336    return;
337  }
338  console.log(`callback:value -> ${JSON.stringify(value)}`)
339});
340```
341
342## setting.getValue<sup>10+</sup>
343
344getValue(context: Context, name: string): Promise\<string>
345
346Obtains the value of a data item in the database. This API uses a promise to return the result.
347
348**Model restriction**: This API can be used only in the stage model.
349
350**System capability**: SystemCapability.Applications.Settings.Core
351
352**Parameters**
353
354| Name | Type   | Mandatory| Description                                                        |
355| ------- | ------- | ---- | ------------------------------------------------------------ |
356| 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).|
357| 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|
358
359**Return value**
360
361| Type            | Description                               |
362| ---------------- | ----------------------------------- |
363| Promise\<string> | Promise used to return the value of the data item.|
364
365**Example**
366
367```js
368import settings from '@ohos.settings';
369const context: Context =  getContext(this);
370settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
371  console.log(`promise:value -> ${JSON.stringify(value)}`)
372});
373```
374
375## settings.getValue<sup>11+</sup>
376
377getValue(context: Context, name: string, domainName: string): Promise\<string>;
378
379Obtains the value of a data item in the database. This API uses a promise to return the result.
380
381**Model restriction**: This API can be used only in the stage model.
382
383**System capability**: SystemCapability.Applications.Settings.Core
384
385**Parameters**
386
387| Name  | Type                  | Mandatory| Description                                                        |
388| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
389| 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).|
390| 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|
391| value    | string                 | Yes  | Value of the data item. The value range varies by service.                  |
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>user security domain|
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): boolean;
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| value    | 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>user security domain|
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
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 SCREEN_BRIGHTNESS_STATUS. (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): 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
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>user security domain|
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| value    | string                 | Yes  | Value of the data item. The value range varies by service.                  |
576|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>user security domain|
577|observer  |  AsyncCallback\<void>  | Yes  | Callback used to return the value of the data item.                  |
578
579**Return value**
580
581| Type            | Description                               |
582| ---------------- | ----------------------------------- |
583| boolean | Returns **true** if the registration is successful; returns **false** otherwise.|
584
585**Example**
586
587```js
588import settings from '@ohos.settings';
589
590const context: Context =  getContext(this);
591settings.registerKeyObserver(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED, (err, value) => {
592  if(err){
593    console.error('Failed to get the setting.${err.message}');
594    return;
595  }
596  console.log(`Promise:value -> $ {JSON.stringify(value)}`);
597});
598```
599
600## settings.unregisterKeyObserver<sup>11+</sup>
601
602unregisterKeyObserver(context: Context, name: string, domainName: string): boolean
603
604Unregisters the observer under the specified domain name. This API returns the result synchronously.
605
606**Model restriction**: This API can be used only in the stage model.
607
608**System capability**: SystemCapability.Applications.Settings.Core
609
610| Name  | Type                  | Mandatory| Description                                                        |
611| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
612| 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).|
613| 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|
614| value    | string                 | Yes  | Value of the data item. The value range varies by service.                  |
615|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>user security domain|
616
617**Return value**
618
619| Type            | Description                               |
620| ---------------- | ----------------------------------- |
621| boolean | Returns **true** if the registration is successful; returns **false** otherwise.|
622
623**Example**
624
625```js
626import settings from '@ohos.settings';
627
628const context: Context =  getContext(this);
629let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS,  settings.domainName.DEVICE_SHARED);
630```
631
632## settings.enableAirplaneMode
633
634enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
635
636Enables or disables airplane mode. This API uses an asynchronous callback to return the result.
637
638This API is not supported currently.
639
640**System capability**: SystemCapability.Applications.Settings.Core
641
642**Parameters**
643
644| Name  | Type                | Mandatory| Description                                           |
645| -------- | -------------------- | ---- | ----------------------------------------------- |
646| enable   | boolean              | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
647| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.                                     |
648
649**Example**
650
651```js
652let isEnabled :boolean = true;
653settings.enableAirplaneMode(isEnabled, (err:Error) => {
654    if (err) {
655        console.log('Failed to enable AirplaneMode.');
656        return;
657    }
658    console.log('Return true if enable.');
659})
660```
661
662## settings.enableAirplaneMode
663
664enableAirplaneMode(enable: boolean): Promise\<void>
665
666Enables or disables airplane mode. This API uses a promise to return the result.
667
668This API is not supported currently.
669
670**System capability**: SystemCapability.Applications.Settings.Core
671
672**Parameters**
673
674| Name| Type   | Mandatory| Description                                           |
675| ------ | ------- | ---- | ----------------------------------------------- |
676| enable | boolean | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
677
678**Return value**
679
680| Type          | Description                     |
681| -------------- | ------------------------- |
682| Promise\<void> | Promise that returns no value.|
683
684**Example**
685
686```js
687let isEnabled :boolean = true;
688settings.enableAirplaneMode(isEnabled).then(() => {
689  console.log('Succeeded in enabling AirplaneMode.');
690}).catch((err:Error) => {
691  console.log(`Failed to enable AirplaneMode. Cause: ${err}`);
692})
693```
694
695## settings.canShowFloating
696
697canShowFloating(callback: AsyncCallback\<boolean>): void
698
699Checks whether the application can be displayed in a floating window. This API uses an asynchronous callback to return the result.
700
701**System capability**: SystemCapability.Applications.Settings.Core
702
703**Parameters**
704
705| Name  | Type                   | Mandatory| Description                                                        |
706| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
707| 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.|
708
709**Example**
710
711```js
712settings.canShowFloating((err:Error, status: boolean) => {
713  if (err) {
714    console.error(`Failed to Checks whether a specified application can show as float window ${err.message} `);
715    return;
716  }
717  console.log('Checks whether a specified application can show as float window.');
718});
719```
720
721## settings.canShowFloating
722
723canShowFloating(): Promise\<boolean>
724
725Checks whether the application can be displayed in a floating window. This API uses a promise to return the result.
726
727**System capability**: SystemCapability.Applications.Settings.Core
728
729**Return value**
730
731| Type             | Description                                                        |
732| ----------------- | ------------------------------------------------------------ |
733| Promise\<boolean> | Promise used to return the result.<br>Returns **true** if the application can be displayed in a floating window; returns **false** otherwise.|
734
735**Example**
736
737```js
738settings.canShowFloating().then((status:boolean) => {
739    console.log('Checks whether a specified application can show as float window.');
740});
741```
742
743## settings.getUriSync<sup>8+</sup>
744
745getUriSync(name: string): string
746
747Obtains the URI of a data item.
748
749**System capability**: SystemCapability.Applications.Settings.Core
750
751**Parameters**
752
753| Name| Type  | Mandatory| Description                                                        |
754| ------ | ------ | ---- | ------------------------------------------------------------ |
755| 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|
756
757**Return value**
758
759| Type  | Description         |
760| ------ | ------------- |
761| string | URI of the data item.|
762
763**Example**
764
765```js
766// Obtain the URI of a data item.
767let uriVar:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
768```
769
770## setting.getURI<sup>(deprecated)</sup>
771
772getURI(name: string, callback: AsyncCallback\<object>): void
773
774Obtains the URI of a data item. This API uses an asynchronous callback to return the result.
775
776> **NOTE**
777>
778> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
779
780**System capability**: SystemCapability.Applications.Settings.Core
781
782**Parameters**
783
784| Name  | Type                  | Mandatory| Description                                                        |
785| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
786| 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|
787| callback | AsyncCallback\<object> | Yes  | Callback used to obtain the URI of the data item.                                 |
788
789**Example**
790
791```js
792settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri:string) => {
793    console.log(`callback:uri -> ${JSON.stringify(uri)}`)
794})
795```
796
797## setting.getURI<sup>(deprecated)</sup>
798
799getURI(name: string): Promise\<object>
800
801Obtains the URI of a data item. This API uses a promise to return the result.
802
803> **NOTE**
804>
805> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided.
806
807**System capability**: SystemCapability.Applications.Settings.Core
808
809**Parameters**
810
811| Name| Type  | Mandatory| Description                                                        |
812| ------ | ------ | ---- | ------------------------------------------------------------ |
813| 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|
814
815**Return value**
816
817| Type            | Description                                |
818| ---------------- | ------------------------------------ |
819| Promise\<object> | Promise used to return the URI of the data item.|
820
821**Example**
822
823```js
824settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri:string) => {
825    console.log(`promise:uri -> ${JSON.stringify(uri)}`)
826})
827```
828
829
830
831## setting.getValue<sup>(deprecated)</sup>
832
833getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
834
835Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
836
837> **NOTE**
838>
839> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settinggetvalue10) instead.
840
841**Model restriction**: This API can be used only in the FA model.
842
843**System capability**: SystemCapability.Applications.Settings.Core
844
845**Parameters**
846
847| Name           | Type                                                        | Mandatory| Description                                                        |
848| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
849| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
850| 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|
851| callback          | AsyncCallback\<object>                                       | Yes  | Callback used to return the value of the data item.                            |
852
853**Example**
854
855```js
856import featureAbility from '@ohos.ability.featureAbility';
857
858let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
859let helper = featureAbility.acquireDataAbilityHelper(uri);
860settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err:Error, value:string) => {
861    if (err) {
862        console.error(`Failed to get the setting. ${err.message} `);
863        return;
864    }
865    console.log(`callback:value -> ${JSON.stringify(value)}`)
866});
867```
868
869## setting.getValue<sup>(deprecated)</sup>
870
871getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
872
873Obtains the value of a data item in the database. This API uses a promise to return the result.
874
875> **NOTE**
876>
877> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settinggetvalue10-1) instead.
878
879**Model restriction**: This API can be used only in the FA model.
880
881**System capability**: SystemCapability.Applications.Settings.Core
882
883**Parameters**
884
885| Name           | Type                                                        | Mandatory| Description                                                        |
886| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
887| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
888| 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|
889
890**Return value**
891
892| Type            | Description                               |
893| ---------------- | ----------------------------------- |
894| Promise\<object> | Promise used to return the value of the data item.|
895
896**Example**
897
898```js
899import featureAbility from '@ohos.ability.featureAbility';
900
901let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
902let helper = featureAbility.acquireDataAbilityHelper(uri);
903settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value:string) => {
904    console.log(`promise:value -> ${JSON.stringify(value)}`)
905});
906```
907
908## settings.getValueSync<sup>(deprecated)</sup>
909
910getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string
911
912Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
913
914> **NOTE**
915>
916> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getValueSync()](#settingsgetvaluesync10) instead.
917
918**Model restriction**: This API can be used only in the FA model.
919
920**System capability**: SystemCapability.Applications.Settings.Core
921
922**Parameters**
923
924| Name           | Type                                                        | Mandatory| Description                                                        |
925| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
926| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
927| 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|
928| 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.|
929
930**Return value**
931
932| Type  | Description            |
933| ------ | ---------------- |
934| string | Value of the data item.|
935
936**Example**
937
938```js
939import featureAbility from '@ohos.ability.featureAbility';
940
941// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
942let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
943let helper = featureAbility.acquireDataAbilityHelper(uri);
944let value:string = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
945```
946
947## settings.setValueSync<sup>(deprecated)</sup>
948
949setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
950
951Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
952
953If 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.
954
955> **NOTE**
956>
957> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setValueSync()](#settingssetvaluesync10) instead.
958
959**Model restriction**: This API can be used only in the FA model.
960
961**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications)
962
963**System capability**: SystemCapability.Applications.Settings.Core
964
965**Parameters**
966
967| Name           | Type                                                        | Mandatory| Description                                                        |
968| ----------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
969| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
970| 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|
971| value             | string                                                       | Yes  | Value of the data item. The value range varies by service.                      |
972
973**Return value**
974
975| Type   | Description                                                        |
976| ------- | ------------------------------------------------------------ |
977| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
978
979**Example**
980
981```js
982import featureAbility from '@ohos.ability.featureAbility';
983
984// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update its value.)
985let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
986let helper = featureAbility.acquireDataAbilityHelper(uri);
987let ret:string = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
988```
989