• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
15## date
16
17Provides data items for setting the time and date formats.
18
19### Attributes
20
21**System capability**: SystemCapability.Applications.settings.Core
22
23| Name               | Type  | Readable| Writable| Description                                                        |
24| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
25| 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.|
26| TIME_FORMAT         | string | Yes  | Yes  | Time format.<br>**12**: 12-hour format.<br>**24**: 24-hour format.|
27| 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; and **false** means the opposite.|
28| 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; and **false** means the opposite.|
29
30## display
31
32Provides data items for setting the display effects.
33
34### Attributes
35
36**System capability**: SystemCapability.Applications.settings.Core
37
38| Name                         | Type  | Readable| Writable| Description                                                        |
39| ----------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
40| FONT_SCALE                    | string | Yes  | Yes  | Scale factor of the font. The value is a floating point number.                                |
41| SCREEN_BRIGHTNESS_STATUS      | string | Yes  | Yes  | Screen brightness. The value ranges from 0 to 255.                              |
42| 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.|
43| AUTO_SCREEN_BRIGHTNESS_MODE   | number | Yes  | Yes  | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is enabled.          |
44| MANUAL_SCREEN_BRIGHTNESS_MODE | number | Yes  | Yes  | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is disabled.          |
45| SCREEN_OFF_TIMEOUT            | string | Yes  | Yes  | Waiting time for the device to enter the sleep state when not in use (unit: ms).  |
46| 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.|
47| 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**.|
48| TRANSITION_ANIMATION_SCALE    | string | Yes  | Yes  | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled.          |
49| WINDOW_ANIMATION_SCALE        | string | Yes  | Yes  | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled.      |
50| 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.|
51
52## general
53
54Provides data items for setting the general information about the device.
55
56### Attributes
57
58**System capability**: SystemCapability.Applications.settings.Core
59
60| Name                            | Type  | Readable| Writable| Description                                                        |
61| -------------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
62| 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.|
63| 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.|
64| 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.|
65| AIRPLANE_MODE_STATUS             | string | Yes  | Yes  | Whether airplane mode is enabled.<br>**1**: Airplane mode is enabled.<br>**0**: Airplane mode is disabled.|
66| 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.|
67| 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.|
68| BOOT_COUNTING                    | string | Yes  | Yes  | Number of boot operations after the device is powered on.                                    |
69| 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.|
70| DEVELOPMENT_SETTINGS_STATUS      | string | Yes  | Yes  | Whether developer options are enabled.<br>**true**: Developer options are enabled.<br>**false**: Developer options are disabled.|
71| DEVICE_NAME                      | string | Yes  | Yes  | Device name.                                                  |
72| 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.|
73| 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.|
74| DEBUG_APP_PACKAGE                | string | Yes  | Yes  | Bundle name of the application to be debugged.                             |
75| ACCESSIBILITY_STATUS             | string | Yes  | Yes  | Whether accessibility is enabled.<br>**1**: Accessibility is enabled.<br>**0**: Accessibility is disabled.|
76| ACTIVATED_ACCESSIBILITY_SERVICES | string | Yes  | Yes  | List of activated accessibility features.                                    |
77| GEOLOCATION_ORIGINS_ALLOWED      | string | Yes  | Yes  | Default geographic location that can be used by the browser. Multiple geographic locations are separated by spaces.      |
78| 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.|
79| TOUCH_EXPLORATION_STATUS         | string | Yes  | Yes  | Whether touch exploration is enabled.<br>**1**: Touch exploration is enabled.<br>**0**: Touch exploration is disabled.|
80
81## input
82
83Provides data items for setting input methods.
84
85### Attributes
86
87**System capability**: SystemCapability.Applications.settings.Core
88
89| Name                                | Type  | Readable| Writable| Description                                                        |
90| ------------------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
91| DEFAULT_INPUT_METHOD                 | string | Yes  | Yes  | Default input method and its ID.                                          |
92| ACTIVATED_INPUT_METHOD_SUB_MODE      | string | Yes  | Yes  | Type and ID of the default input method keyboard.                                  |
93| 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.|
94| 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.|
95| 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.|
96| 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.|
97| 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 |
98| 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.|
99
100## network
101
102Provides data items for setting network information.
103
104### Attributes
105
106**System capability**: SystemCapability.Applications.settings.Core
107
108| Name                    | Type  | Readable| Writable| Description                                                        |
109| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
110| DATA_ROAMING_STATUS      | string | Yes  | Yes  | Whether data roaming is enabled.<br>**true**: Data roaming is enabled.<br>**false**: Data roaming is disabled.|
111| 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 (:).|
112| NETWORK_PREFERENCE_USAGE | string | Yes  | Yes  | User preferences for the network to use.                                  |
113
114## phone
115
116Provides data items for setting the modes of answering incoming and outgoing calls.
117
118### Attributes
119
120**System capability**: SystemCapability.Applications.settings.Core
121
122| Name              | Type  | Readable| Writable| Description                                                        |
123| ------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
124| 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.|
125
126## sound
127
128Provides data items for setting the sound effects.
129
130### Attributes
131
132**System capability**: SystemCapability.Applications.settings.Core
133
134| Name                        | Type  | Readable| Writable| Description                                                        |
135| ---------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
136| 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.|
137| DEFAULT_ALARM_ALERT          | string | Yes  | Yes  | Storage area of the system default alarms and alerts.                                    |
138| 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.|
139| 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.|
140| 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**.|
141| 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**.|
142| DEFAULT_NOTIFICATION_SOUND   | string | Yes  | Yes  | Storage area of the system default notification tone.                                  |
143| DEFAULT_RINGTONE             | string | Yes  | Yes  | Storage area of the system default ringtone.                                    |
144| 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.  |
145| 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.|
146| HAPTIC_FEEDBACK_STATUS       | string | Yes  | Yes  | Whether haptic feedback is enabled.<br>**true**: Haptic feedback is enabled.<br>**false**: Haptic feedback is disabled.|
147
148## TTS
149
150Provides data items for setting text-to-speech (TTS) information.
151
152### Attributes
153
154**System capability**: SystemCapability.Applications.settings.Core
155
156| Name               | Type  | Readable| Writable| Description                                                        |
157| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
158| 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.|
159| DEFAULT_TTS_RATE    | string | Yes  | Yes  | Default voice rate of the TTS engine.<br>100 = 1x.                        |
160| DEFAULT_TTS_SYNTH   | string | Yes  | Yes  | Default TTS engine.                                               |
161| ENABLED_TTS_PLUGINS | string | Yes  | Yes  | List of activated plug-in packages used for TTS. Multiple plug-in packages are separated by spaces.          |
162
163
164## wireless
165
166Provides data items for setting wireless network information.
167
168### Attributes
169
170**System capability**: SystemCapability.Applications.settings.Core
171
172| Name                             | Type  | Readable| Writable| Description                                                        |
173| --------------------------------- | ------ | ---- | ---- | ------------------------------------------------------------ |
174| 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.|
175| 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.|
176| 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**.|
177| BLUETOOTH_RADIO                   | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that Bluetooth is disabled in airplane mode.|
178| CELL_RADIO                        | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that cellular radio is disabled in airplane mode.|
179| NFC_RADIO                         | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that NFC is disabled in airplane mode.|
180| WIFI_RADIO                        | string | Yes  | No  | A value of **AIRPLANE_MODE_RADIOS** to indicate that Wi-Fi is disabled in airplane mode.|
181| BLUETOOTH_STATUS                  | string | Yes  | Yes  | Whether Bluetooth is available.<br>**true**: Bluetooth is available.<br>**false**: Bluetooth is unavailable.|
182| 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.|
183| WIFI_DHCP_MAX_RETRY_COUNT         | string | Yes  | Yes  | Maximum number of attempts to obtain an IP address from the DHCP server.                    |
184| 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. |
185| WIFI_STATUS                       | string | Yes  | Yes  | Whether Wi-Fi is available.<br>**true**: Wi-Fi is available.<br>**false**: Wi-Fi is unavailable.|
186| 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.|
187
188## setting.getURI
189
190getURI(name: string, callback: AsyncCallback\<object>): void
191
192Obtains the URI of a data item. This API uses an asynchronous callback to return the result.
193
194**System capability**: SystemCapability.Applications.settings.Core
195
196**Parameters**
197
198| Name  | Type                  | Mandatory| Description                                                        |
199| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
200| 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|
201| callback | AsyncCallback\<object> | Yes  | Callback used to obtain the URI of the data item.                                 |
202
203**Example**
204
205```js
206settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri) => {
207    console.log(`callback:uri -> ${JSON.stringify(uri)}`)
208})
209```
210
211## setting.getURI
212
213getURI(name: string): Promise\<object>
214
215Obtains the URI of a data item. This API uses a promise to return the result.
216
217**System capability**: SystemCapability.Applications.settings.Core
218
219**Parameters**
220
221| Name| Type  | Mandatory| Description                                                        |
222| ------ | ------ | ---- | ------------------------------------------------------------ |
223| 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|
224
225**Return value**
226
227| Type            | Description                                |
228| ---------------- | ------------------------------------ |
229| Promise\<object> | Promise used to return the URI of the data item.|
230
231**Example**
232
233```js
234settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri) => {
235    console.log(`promise:uri -> ${JSON.stringify(uri)}`)
236})
237```
238
239## setting.getValue
240
241getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void
242
243Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result.
244
245**System capability**: SystemCapability.Applications.settings.Core
246
247**Parameters**
248
249| Name           | Type                                             | Mandatory| Description                                                        |
250| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
251| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
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| callback          | AsyncCallback\<object>                            | Yes  | Callback used to return the value of the data item.                            |
254
255**Example**
256
257```js
258import featureAbility from '@ohos.ability.featureAbility';
259
260let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
261let helper = featureAbility.acquireDataAbilityHelper(uri);
262settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => {
263    if (err) {
264        console.error(`Failed to get the setting. ${err.message} `);
265        return;
266    }
267    console.log(`callback:value -> ${JSON.stringify(value)}`)
268});
269```
270
271## setting.getValue
272
273getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
274
275Obtains the value of a data item in the database. This API uses a promise to return the result.
276
277**System capability**: SystemCapability.Applications.settings.Core
278
279**Parameters**
280
281| Name           | Type                                             | Mandatory| Description                                                        |
282| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
283| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
284| 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|
285
286**Return value**
287
288| Type            | Description                               |
289| ---------------- | ----------------------------------- |
290| Promise\<object> | Promise used to return the value of the data item.|
291
292**Example**
293
294```js
295import featureAbility from '@ohos.ability.featureAbility';
296
297let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
298let helper = featureAbility.acquireDataAbilityHelper(uri);
299settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => {
300    console.log(`promise:value -> ${JSON.stringify(value)}`)
301});
302```
303
304## settings.setValue
305
306setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback\<boolean>): void
307
308Sets the value for a data item. This API uses an asynchronous callback to return the result.
309
310**System API**: This is a system API.
311
312**System capability**: SystemCapability.Applications.settings.Core
313
314**Parameters**
315
316| Name           | Type                                             | Mandatory| Description                                                        |
317| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
318| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
319| 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|
320| value             | object                                            | Yes  | Value of the data item. The value range varies by service.                              |
321| callback          | AsyncCallback\<boolean>                           | Yes  | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.              |
322
323**Example**
324
325```js
326import featureAbility from '@ohos.ability.featureAbility';
327
328// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update the value of the data item.)
329let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
330let helper = featureAbility.acquireDataAbilityHelper(uri);
331settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => {
332    console.log('Callback return whether value is set.');
333});
334```
335
336## settings.setValue
337
338setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise\<boolean>
339
340Sets the value for a data item. This API uses a promise to return the result.
341
342**System API**: This is a system API.
343
344**System capability**: SystemCapability.Applications.settings.Core
345
346**Parameters**
347
348| Name           | Type                                             | Mandatory| Description                                                        |
349| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
350| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
351| 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|
352| value             | object                                            | Yes  | Value of the data item. The value range varies by service.                              |
353
354**Return value**
355
356| Type             | Description                                              |
357| ----------------- | -------------------------------------------------- |
358| Promise\<boolean> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.|
359
360**Example**
361
362```js
363import featureAbility from '@ohos.ability.featureAbility';
364
365// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update the value of the data item.)
366let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
367let helper = featureAbility.acquireDataAbilityHelper(uri);
368settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => {
369    console.log('Callback return whether value is set.');
370});
371```
372
373## settings.enableAirplaneMode
374
375enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
376
377Enables or disables airplane mode. This API uses an asynchronous callback to return the result.
378
379**System capability**: SystemCapability.Applications.settings.Core
380
381**Parameters**
382
383| Name  | Type                | Mandatory| Description                                           |
384| -------- | -------------------- | ---- | ----------------------------------------------- |
385| enable   | boolean              | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
386| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.                                     |
387
388**Example**
389
390```js
391let isEnabled = true;
392settings.enableAirplaneMode(isEnabled, (err) => {
393    if (err) {
394        console.log('Failed to enable AirplaneMode.');
395        return;
396    }
397    console.log('Return true if enable.');
398})
399```
400
401## settings.enableAirplaneMode
402
403enableAirplaneMode(enable: boolean): Promise\<void>
404
405Enables or disables airplane mode. This API uses a promise to return the result.
406
407**System capability**: SystemCapability.Applications.settings.Core
408
409**Parameters**
410
411| Name| Type   | Mandatory| Description                                           |
412| ------ | ------- | ---- | ----------------------------------------------- |
413| enable | boolean | Yes  | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.|
414
415**Return value**
416
417| Type          | Description                     |
418| -------------- | ------------------------- |
419| Promise\<void> | Promise that returns no value.|
420
421**Example**
422
423```js
424let isEnabled = true;
425settingsenableAirplaneMode(isEnabled).then((err) => {
426    if (err) {
427        console.log('Failed to enable AirplaneMode.');
428        return;
429    }
430    console.log('Return true if enable.');
431});
432```
433
434## settings.canShowFloating
435
436canShowFloating(callback: AsyncCallback\<boolean>): void
437
438Checks whether the application can be displayed in a floating window. This API uses an asynchronous callback to return the result.
439
440**System capability**: SystemCapability.Applications.settings.Core
441
442**Parameters**
443
444| Name  | Type                   | Mandatory| Description                                                        |
445| -------- | ----------------------- | ---- | ------------------------------------------------------------ |
446| 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.|
447
448**Example**
449
450```js
451settings.canShowFloating((status) => {
452    console.log('Checks whether a specified application can show as float window.');
453});
454```
455
456## settings.canShowFloating
457
458canShowFloating(): Promise\<boolean>
459
460Checks whether the application can be displayed in a floating window. This API uses a promise to return the result.
461
462**System capability**: SystemCapability.Applications.settings.Core
463
464**Return value**
465
466| Type             | Description                                                        |
467| ----------------- | ------------------------------------------------------------ |
468| Promise\<boolean> | Promise used to return the result.<br>Returns **true** if the application can be displayed in a floating window; returns **false** otherwise.|
469
470**Example**
471
472```js
473settings.canShowFloating().then((status) => {
474    console.log('Checks whether a specified application can show as float window.');
475});
476```
477
478## settings.getUriSync<sup>8+</sup>
479
480getUriSync(name: string): string
481
482Obtains the URI of a data item.
483
484**System capability**: SystemCapability.Applications.settings.Core
485
486**Parameters**
487
488| Name| Type  | Mandatory| Description                                                        |
489| ------ | ------ | ---- | ------------------------------------------------------------ |
490| 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|
491
492**Return value**
493
494| Type  | Description         |
495| ------ | ------------- |
496| string | URI of the data item.|
497
498**Example**
499
500```js
501// Obtain the URI of a data item.
502let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
503```
504
505## settings.getValueSync<sup>8+</sup>
506
507getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string
508
509Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously.
510
511**System capability**: SystemCapability.Applications.settings.Core
512
513**Parameters**
514
515| Name           | Type                                             | Mandatory| Description                                                        |
516| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
517| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
518| 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|
519| defValue          | string                                            | Yes  | Default value, which is returned when the value of a data item is not found in the database. Set this attribute as needed.|
520
521**Return value**
522
523| Type  | Description            |
524| ------ | ---------------- |
525| string | Value of the data item.|
526
527**Example**
528
529```js
530import featureAbility from '@ohos.ability.featureAbility';
531
532// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database).
533let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
534let helper = featureAbility.acquireDataAbilityHelper(uri);
535let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10');
536```
537
538## settings.setValueSync<sup>8+</sup>
539
540setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
541
542Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously.
543
544If 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.
545
546**Required permissions**: ohos.permission.MANAGE_SECUER_SETTINGS (available only to system applications)
547
548**System capability**: SystemCapability.Applications.settings.Core
549
550**Parameters**
551
552| Name           | Type                                             | Mandatory| Description                                                        |
553| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
554| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes  | **DataAbilityHelper** class.                                            |
555| name              | string                                            | Yes  | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items|
556| value             | string                                            | Yes  | Value of the data item. The value range varies by service.                      |
557
558**Return value**
559
560| Type   | Description                                                        |
561| ------- | ------------------------------------------------------------ |
562| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
563
564**Example**
565
566```js
567import featureAbility from '@ohos.ability.featureAbility';
568
569// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update the value of the data item.)
570let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS);
571let helper = featureAbility.acquireDataAbilityHelper(uri);
572let ret = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100');
573```
574