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 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 189## settings.setValue 190 191setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback\<boolean>): void 192 193Sets the value for a data item. This API uses an asynchronous callback to return the result. 194 195**System API**: This is a system API. 196 197**System capability**: SystemCapability.Applications.settings.Core 198 199**Parameters** 200 201| Name | Type | Mandatory| Description | 202| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 203| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 204| 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| 205| value | object | Yes | Value of the data item. The value range varies by service. | 206| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. Returns **true** if the operation is successful; returns **false** otherwise. | 207 208**Example** 209 210```js 211import featureAbility from '@ohos.ability.featureAbility'; 212 213// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.) 214let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 215let helper = featureAbility.acquireDataAbilityHelper(uri); 216// @ts-ignore 217// The value of the data item is a string. 218settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => { 219 console.log('Callback return whether value is set.'); 220}); 221``` 222 223## settings.setValue 224 225setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise\<boolean> 226 227Sets the value for a data item. This API uses a promise to return the result. 228 229**System API**: This is a system API. 230 231**System capability**: SystemCapability.Applications.settings.Core 232 233**Parameters** 234 235| Name | Type | Mandatory| Description | 236| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 237| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 238| 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| 239| value | object | Yes | Value of the data item. The value range varies by service. | 240 241**Return value** 242 243| Type | Description | 244| ----------------- | -------------------------------------------------- | 245| Promise\<boolean> | Promise used to return the result. Returns **true** if the operation is successful; returns **false** otherwise.| 246 247**Example** 248 249```js 250import featureAbility from '@ohos.ability.featureAbility'; 251 252// 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.) 253let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 254let helper = featureAbility.acquireDataAbilityHelper(uri); 255// @ts-ignore 256// The value of the data item is a string. 257settings.setValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => { 258 console.log('Callback return whether value is set.'); 259}); 260``` 261 262## settings.enableAirplaneMode 263 264enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void 265 266Enables or disables airplane mode. This API uses an asynchronous callback to return the result. 267 268**System capability**: SystemCapability.Applications.settings.Core 269 270**Parameters** 271 272| Name | Type | Mandatory| Description | 273| -------- | -------------------- | ---- | ----------------------------------------------- | 274| enable | boolean | Yes | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.| 275| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | 276 277**Example** 278 279```js 280let isEnabled = true; 281settings.enableAirplaneMode(isEnabled, (err) => { 282 if (err) { 283 console.log('Failed to enable AirplaneMode.'); 284 return; 285 } 286 console.log('Return true if enable.'); 287}) 288``` 289 290## settings.enableAirplaneMode 291 292enableAirplaneMode(enable: boolean): Promise\<void> 293 294Enables or disables airplane mode. This API uses a promise to return the result. 295 296**System capability**: SystemCapability.Applications.settings.Core 297 298**Parameters** 299 300| Name| Type | Mandatory| Description | 301| ------ | ------- | ---- | ----------------------------------------------- | 302| enable | boolean | Yes | Whether airplane mode is enabled. **true** means that airplane mode is enabled, and **false** means the opposite.| 303 304**Return value** 305 306| Type | Description | 307| -------------- | ------------------------- | 308| Promise\<void> | Promise that returns no value.| 309 310**Example** 311 312```js 313let isEnabled = true; 314settings.enableAirplaneMode(isEnabled).then(() => { 315 console.log('Succeeded in enabling AirplaneMode.'); 316}).catch((err) => { 317 console.log(`Failed to enable AirplaneMode. Cause: ${err}`); 318}) 319``` 320 321## settings.canShowFloating 322 323canShowFloating(callback: AsyncCallback\<boolean>): void 324 325Checks whether the application can be displayed in a floating window. This API uses an asynchronous callback to return the result. 326 327**System capability**: SystemCapability.Applications.settings.Core 328 329**Parameters** 330 331| Name | Type | Mandatory| Description | 332| -------- | ----------------------- | ---- | ------------------------------------------------------------ | 333| 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.| 334 335**Example** 336 337```js 338settings.canShowFloating((status) => { 339 console.log('Checks whether a specified application can show as float window.'); 340}); 341``` 342 343## settings.canShowFloating 344 345canShowFloating(): Promise\<boolean> 346 347Checks whether the application can be displayed in a floating window. This API uses a promise to return the result. 348 349**System capability**: SystemCapability.Applications.settings.Core 350 351**Return value** 352 353| Type | Description | 354| ----------------- | ------------------------------------------------------------ | 355| Promise\<boolean> | Promise used to return the result.<br>Returns **true** if the application can be displayed in a floating window; returns **false** otherwise.| 356 357**Example** 358 359```js 360settings.canShowFloating().then((status) => { 361 console.log('Checks whether a specified application can show as float window.'); 362}); 363``` 364 365## settings.getUriSync<sup>8+</sup> 366 367getUriSync(name: string): string 368 369Obtains the URI of a data item. 370 371**System capability**: SystemCapability.Applications.settings.Core 372 373**Parameters** 374 375| Name| Type | Mandatory| Description | 376| ------ | ------ | ---- | ------------------------------------------------------------ | 377| 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| 378 379**Return value** 380 381| Type | Description | 382| ------ | ------------- | 383| string | URI of the data item.| 384 385**Example** 386 387```js 388// Obtain the URI of a data item. 389let urivar = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 390``` 391 392## setting.getURI<sup>(deprecated)</sup> 393 394getURI(name: string, callback: AsyncCallback\<object>): void 395 396Obtains the URI of a data item. This API uses an asynchronous callback to return the result. 397 398> **NOTE** 399> 400> This API is supported since API version 7 and deprecated since API version 9. 401 402**System capability**: SystemCapability.Applications.settings.Core 403 404**Parameters** 405 406| Name | Type | Mandatory| Description | 407| -------- | ---------------------- | ---- | ------------------------------------------------------------ | 408| 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| 409| callback | AsyncCallback\<object> | Yes | Callback used to obtain the URI of the data item. | 410 411**Example** 412 413```js 414settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri) => { 415 console.log(`callback:uri -> ${JSON.stringify(uri)}`) 416}) 417``` 418 419## setting.getURI<sup>(deprecated)</sup> 420 421getURI(name: string): Promise\<object> 422 423Obtains the URI of a data item. This API uses a promise to return the result. 424 425> **NOTE** 426> 427> This API is supported since API version 7 and deprecated since API version 9. 428 429**System capability**: SystemCapability.Applications.settings.Core 430 431**Parameters** 432 433| Name| Type | Mandatory| Description | 434| ------ | ------ | ---- | ------------------------------------------------------------ | 435| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| 436 437**Return value** 438 439| Type | Description | 440| ---------------- | ------------------------------------ | 441| Promise\<object> | Promise used to return the URI of the data item.| 442 443**Example** 444 445```js 446settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri) => { 447 console.log(`promise:uri -> ${JSON.stringify(uri)}`) 448}) 449``` 450 451## setting.getValue<sup>(deprecated)</sup> 452 453getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void 454 455Obtains the value of a data item in the database. This API uses an asynchronous callback to return the result. 456 457> **NOTE** 458> 459> This API is supported since API version 7 and deprecated since API version 9. 460 461**Model restriction**: This API can be used only in the FA model. 462 463**System capability**: SystemCapability.Applications.settings.Core 464 465**Parameters** 466 467| Name | Type | Mandatory| Description | 468| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 469| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 470| 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| 471| callback | AsyncCallback\<object> | Yes | Callback used to return the value of the data item. | 472 473**Example** 474 475```js 476import featureAbility from '@ohos.ability.featureAbility'; 477 478let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 479let helper = featureAbility.acquireDataAbilityHelper(uri); 480settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => { 481 if (err) { 482 console.error(`Failed to get the setting. ${err.message} `); 483 return; 484 } 485 console.log(`callback:value -> ${JSON.stringify(value)}`) 486}); 487``` 488 489## setting.getValue<sup>(deprecated)</sup> 490 491getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object> 492 493Obtains the value of a data item in the database. This API uses a promise to return the result. 494 495> **NOTE** 496> 497> This API is supported since API version 7 and deprecated since API version 9. 498 499**Model restriction**: This API can be used only in the FA model. 500 501**System capability**: SystemCapability.Applications.settings.Core 502 503**Parameters** 504 505| Name | Type | Mandatory| Description | 506| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 507| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 508| 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| 509 510**Return value** 511 512| Type | Description | 513| ---------------- | ----------------------------------- | 514| Promise\<object> | Promise used to return the value of the data item.| 515 516**Example** 517 518```js 519import featureAbility from '@ohos.ability.featureAbility'; 520 521let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 522let helper = featureAbility.acquireDataAbilityHelper(uri); 523settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => { 524 console.log(`promise:value -> ${JSON.stringify(value)}`) 525}); 526``` 527 528## settings.getValueSync<sup>(deprecated)</sup> 529 530getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string 531 532Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously. 533 534> **NOTE** 535> 536> This API is supported since API version 8 and deprecated since API version 9. 537 538**Model restriction**: This API can be used only in the FA model. 539 540**System capability**: SystemCapability.Applications.settings.Core 541 542**Parameters** 543 544| Name | Type | Mandatory| Description | 545| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 546| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 547| 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| 548| 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.| 549 550**Return value** 551 552| Type | Description | 553| ------ | ---------------- | 554| string | Value of the data item.| 555 556**Example** 557 558```js 559import featureAbility from '@ohos.ability.featureAbility'; 560 561// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database). 562let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 563let helper = featureAbility.acquireDataAbilityHelper(uri); 564let value = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10'); 565``` 566 567## settings.setValueSync<sup>(deprecated)</sup> 568 569setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean 570 571Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously. 572 573If 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. 574 575> **NOTE** 576> 577> This API is supported since API version 8 and deprecated since API version 9. 578 579**Model restriction**: This API can be used only in the FA model. 580 581**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS (available only to system applications) 582 583**System capability**: SystemCapability.Applications.settings.Core 584 585**Parameters** 586 587| Name | Type | Mandatory| Description | 588| ----------------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ | 589| dataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 590| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| 591| value | string | Yes | Value of the data item. The value range varies by service. | 592 593**Return value** 594 595| Type | Description | 596| ------- | ------------------------------------------------------------ | 597| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.| 598 599**Example** 600 601```js 602import featureAbility from '@ohos.ability.featureAbility'; 603 604// 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.) 605let uri = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 606let helper = featureAbility.acquireDataAbilityHelper(uri); 607let ret = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100'); 608``` 609