1# @ohos.settings (Data Item Settings) 2 3<!--Kit: Basic Services Kit--> 4<!--Subsystem: Applications--> 5<!--Owner: @YingCong--> 6<!--Designer: @Kun_Wu--> 7<!--Tester: @dyx118186878--> 8<!--Adviser: @zhang_yixin13--> 9 10The **settings** module provides APIs for setting data items. 11 12> **NOTE** 13> 14> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. 15> 16> - If no value is obtained for the accessed data item, it indicates that the current system app does not add the value of the data item to the database. 17 18## Modules to Import 19 20```js 21import { settings } from '@kit.BasicServicesKit'; 22``` 23## domainName 24 25Provides the domain name. 26 27### Properties 28 29**System capability**: SystemCapability.Applications.Settings.Core 30 31| Name | Type | Readable| Writable| Description | 32|-----------------------------| ------ | ---- | ---- |----------------------| 33| DEVICE_SHARED<sup>11+</sup> | string | Yes | Yes | Shared device domain. All configurations in this domain are not distinguished between multiple users.| 34| USER_PROPERTY<sup>11+</sup> | string | Yes | Yes | User attribute domain. All configurations in this domain are distinguished between multiple users.| 35 36## date 37 38Provides data items for setting the time and date formats. (Not supported yet.) 39 40### Properties 41 42**System capability**: SystemCapability.Applications.Settings.Core 43 44| Name | Type | Readable| Writable| Description | 45| ------------------- | ------ | ---- | ---- |----------------------------------------------------------------------------| 46| 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.| 47| TIME_FORMAT | string | Yes | Yes | Time format. The options are as follows:<br>- **12**: 12-hour format.<br>- **24**: 24-hour format. | 48| 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>- **true**: Information is automatically obtained.<br>- **false**: Information is not automatically obtained. | 49| AUTO_GAIN_TIME_ZONE | string | Yes | Yes | Whether the time zone is automatically obtained from NITZ.<br>- **1**: Time zone is automatically obtained.<br>- **false**: Time zone is not automatically obtained. | 50 51## display 52 53Provides data items for setting the display effects. (Not supported yet.) 54 55### Properties 56 57**System capability**: SystemCapability.Applications.Settings.Core 58 59| Name | Type | Readable| Writable| Description | 60| ----------------------------- | ------ | ---- | ---- |----------------------------------------------------------------------------------------------------------------------| 61| FONT_SCALE | string | Yes | Yes | Scale factor of the font. The value is a floating point number. | 62| SCREEN_BRIGHTNESS_STATUS | string | Yes | Yes | Screen brightness, with the value ranging from 0 to 255. | 63| 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. | 64| AUTO_SCREEN_BRIGHTNESS_MODE | number | Yes | Yes | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is enabled. | 65| MANUAL_SCREEN_BRIGHTNESS_MODE | number | Yes | Yes | Value of **AUTO_SCREEN_BRIGHTNESS** when automatic screen brightness adjustment is disabled. | 66| SCREEN_OFF_TIMEOUT | string | Yes | Yes | Waiting time for the device to enter the sleep state when not in use (unit: ms). | 67| DEFAULT_SCREEN_ROTATION | string | Yes | Yes | This attribute is invalid when screen auto-rotation is enabled; otherwise, the following options are available:<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.| 68| ANIMATOR_DURATION_SCALE | string | Yes | Yes | Scale factor for the animation duration, which affects the start delay and duration of all such animations.<br>- **0**: The animation ends immediately. The default value is **1**. | 69| TRANSITION_ANIMATION_SCALE | string | Yes | Yes | Scale factor for transition animations.<br>The value **0** indicates that the transition animations are disabled. | 70| WINDOW_ANIMATION_SCALE | string | Yes | Yes | Scale factor for normal window animations.<br>The value **0** indicates that window animations are disabled. | 71| 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. | 72 73## general 74 75Provides data items for setting the general information about the device. (Not supported yet.) 76 77### Properties 78 79**System capability**: SystemCapability.Applications.Settings.Core 80 81| Name | Type | Readable| Writable| Description | 82| -------------------------------- | ------ | ---- | ---- |-------------------------------------------------------------------------------------------------------------------------------------| 83| SETUP_WIZARD_FINISHED | string | Yes | Yes | Whether the startup wizard has been run.<br>- **0**: The startup wizard is not run.<br>- Other than **0**: The startup wizard has been run. | 84| 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.| 85| 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. | 86| 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. | 87| 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. | 88| BOOT_COUNTING | string | Yes | Yes | Number of boot operations after the device is powered on. | 89| 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. | 90| DEVICE_NAME | string | Yes | Yes | Device name. | 91| 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. | 92| 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. | 93| DEBUG_APP_PACKAGE | string | Yes | Yes | Bundle name of the application to be debugged. | 94| ACCESSIBILITY_STATUS | string | Yes | Yes | Whether accessibility is enabled.<br>- **1**: Accessibility is enabled.<br>- **0**: Accessibility is disabled. | 95| ACTIVATED_ACCESSIBILITY_SERVICES | string | Yes | Yes | List of activated accessibility features. | 96| GEOLOCATION_ORIGINS_ALLOWED | string | Yes | Yes | Default geographic location that can be used by the browser. Multiple geographic locations are separated by spaces. | 97| 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 will skip all introductory hints at the first startup.<br>- **0**: The application does not skip all introductory hints at the first startup. | 98| TOUCH_EXPLORATION_STATUS | string | Yes | Yes | Whether touch exploration is enabled.<br>- **1**: Touch exploration is enabled.<br>- **0**: Touch exploration is disabled. | 99 100## input 101 102Provides data items for setting input methods. (Not supported yet.) 103 104### Properties 105 106**System capability**: SystemCapability.Applications.Settings.Core 107 108| Name | Type | Readable| Writable| Description | 109| ------------------------------------ | ------ | ---- | ---- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 110| DEFAULT_INPUT_METHOD | string | Yes | Yes | Default input method and its ID. | 111| ACTIVATED_INPUT_METHOD_SUB_MODE | string | Yes | Yes | Type and ID of the default input method keyboard. | 112| 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.<br>The IDs are separated by colons (:), and keyboard types are separated by semicolons (;).<br>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.| 113| 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. | 114| 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. | 115| 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. | 116| 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 | 117| 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. | 118 119## network 120 121Provides data items for setting network information. (Not supported yet.) 122 123### Properties 124 125**System capability**: SystemCapability.Applications.Settings.Core 126 127| Name | Type | Readable| Writable| Description | 128| ------------------------ | ------ | ---- | ---- |----------------------------------------------------------| 129| DATA_ROAMING_STATUS | string | Yes | Yes | Whether data roaming is enabled.<br>- **true**: Data roaming is enabled.<br>- **false**: Data roaming is disabled.| 130| 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 (:). | 131| NETWORK_PREFERENCE_USAGE | string | Yes | Yes | User preferences for the network to use. | 132 133## phone 134 135Provides data items for setting the modes of answering incoming and outgoing calls. (Not supported yet.) 136 137### Properties 138 139**System capability**: SystemCapability.Applications.Settings.Core 140 141| Name | Type | Readable| Writable| Description | 142| ------------------ | ------ | ---- | ---- |--------------------------------------------------------------------------------------------| 143| RTT_CALLING_STATUS | string | Yes | Yes | Whether the real-time text (RTT) call 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.| 144 145## sound 146 147Provides data items for setting the sound effects. (Not supported yet.) 148 149### Properties 150 151**System capability**: SystemCapability.Applications.Settings.Core 152 153| Name | Type | Readable| Writable| Description | 154| ---------------------------- | ------ | ---- | ---- |--------------------------------------------------------------------------| 155| 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<br>and affects only the scenario where the device rings for an incoming call. It does not affect any other application or scenario.| 156| DEFAULT_ALARM_ALERT | string | Yes | Yes | Storage area of the system default alarms and alerts. | 157| 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. | 158| 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. | 159| AFFECTED_MODE_RINGER_STREAMS | string | Yes | Yes | Effect on audio streams determined by changes in 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 DND mode, set the corresponding bit to **1**. | 160| 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**. | 161| DEFAULT_NOTIFICATION_SOUND | string | Yes | Yes | Storage area of the system default notification tone. | 162| DEFAULT_RINGTONE | string | Yes | Yes | Storage area of the system default ringtone. | 163| 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. | 164| 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. | 165| HAPTIC_FEEDBACK_STATUS | string | Yes | Yes | Whether haptic feedback is enabled.<br>- **true**: Haptic feedback is enabled.<br>- **false**: Haptic feedback is disabled. | 166 167## TTS 168 169Provides data items for setting text-to-speech (TTS) information. (Not supported yet.) 170 171### Properties 172 173**System capability**: SystemCapability.Applications.Settings.Core 174 175| Name | Type | Readable| Writable| Description | 176| ------------------- | ------ | ---- | ---- | ------------------------------------------------------------ | 177| 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.| 178| DEFAULT_TTS_RATE | string | Yes | Yes | Default voice rate of the TTS engine.<br>100 = 1x. | 179| DEFAULT_TTS_SYNTH | string | Yes | Yes | Default TTS engine. | 180| ENABLED_TTS_PLUGINS | string | Yes | Yes | List of activated plug-in packages used for TTS. Multiple plug-in packages are separated by spaces. | 181 182 183## wireless 184 185Provides data items for setting wireless network information. (Not supported yet.) 186 187### Properties 188 189**System capability**: SystemCapability.Applications.Settings.Core 190 191| Name | Type | Readable| Writable| Description | 192| --------------------------------- | ------ | ---- | ---- |----------------------------------------------------------------------------------------------------------| 193| 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. | 194| 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. | 195| 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 (,).<br>The list can include the following: **BLUETOOTH_RADIO**, **CELL_RADIO**, **NFC_RADIO**, and **WIFI_RADIO**.| 196| BLUETOOTH_RADIO | string | Yes | No | A value of **AIRPLANE_MODE_RADIOS** to indicate that Bluetooth is disabled in airplane mode. | 197| CELL_RADIO | string | Yes | No | A value of **AIRPLANE_MODE_RADIOS** to indicate that cellular radio is disabled in airplane mode. | 198| NFC_RADIO | string | Yes | No | A value of **AIRPLANE_MODE_RADIOS** to indicate that NFC is disabled in airplane mode. | 199| WIFI_RADIO | string | Yes | No | A value of **AIRPLANE_MODE_RADIOS** to indicate that Wi-Fi is disabled in airplane mode. | 200| BLUETOOTH_STATUS | string | Yes | Yes | Whether Bluetooth is available.<br>- **true**: Bluetooth is available.<br>- **false**: Bluetooth is unavailable. | 201| 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. | 202| WIFI_DHCP_MAX_RETRY_COUNT | string | Yes | Yes | Maximum number of attempts to obtain an IP address from the DHCP server. | 203| WIFI_TO_MOBILE_DATA_AWAKE_TIMEOUT | string | Yes | Yes | Maximum duration to hold a wake lock when waiting for the mobile data connection after the Wi-Fi connection is disconnected. | 204| WIFI_STATUS | string | Yes | Yes | Whether Wi-Fi is available.<br>- **true**: Wi-Fi is available.<br>- **false**: Wi-Fi is unavailable. | 205| 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. | 206 207 208## settings.setValue<sup>10+</sup> 209 210setValue(context: Context, name: string, value: string, callback: AsyncCallback\<boolean>): void 211 212Sets the value for a data item in the **DEVICE_SHARED** domain of the database. This API uses an asynchronous callback to return the result. 213 214**Model restriction**: This API can be used only in the stage model. 215 216**System capability**: SystemCapability.Applications.Settings.Core 217 218**Required permissions**: ohos.permission.MANAGE_SETTINGS (available only to system applications) 219 220**Parameters** 221 222| Name | Type | Mandatory| Description | 223| -------- | ----------------------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------| 224| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 225| 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 | 226| value | string | Yes | Value of the data item. The value range varies by service. | 227| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result. The value **true** means that the operation is successful, and **false** means the opposite. | 228 229**Example** 230 231<!--code_no_check--> 232```js 233import { settings } from '@kit.BasicServicesKit'; 234import { common } from '@kit.AbilityKit'; 235 236// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.) 237// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 238const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 239settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', (status) => { 240 console.log('Callback return whether value is set.'); 241}); 242``` 243 244## settings.setValue<sup>10+</sup> 245 246setValue(context: Context, name: string, value: string): Promise\<boolean> 247 248Sets the value for a data item in the **DEVICE_SHARED** domain of the database. This API uses a promise to return the result. 249 250**Model restriction**: This API can be used only in the stage model. 251 252**System capability**: SystemCapability.Applications.Settings.Core 253 254**Required permissions**: ohos.permission.MANAGE_SETTINGS (available only to system applications) 255 256**Parameters** 257 258| Name | Type | Mandatory| Description | 259| ------- | ------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------| 260| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 261| 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 | 262| value | string | Yes | Value of the data item. The value range varies by service. | 263 264**Return value** 265 266| Type | Description | 267| ----------------- |---------------------------------------| 268| Promise\<boolean> | Promise used to return the result. The value **true** means that the operation is successful, and **false** means the opposite.| 269 270**Example** 271 272<!--code_no_check--> 273```js 274import { settings } from '@kit.BasicServicesKit'; 275import { common } from '@kit.AbilityKit'; 276 277// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.) 278// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 279const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 280settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100').then((status) => { 281 console.log('Callback return whether value is set.'); 282}); 283``` 284 285## settings.setValue<sup>11+</sup> 286 287setValue(context: Context, name: string, value: string, domainName: string): Promise\<boolean> 288 289Sets the value for a data item. This API uses a promise to return the result. 290 291**Model restriction**: This API can be used only in the stage model. 292 293**System capability**: SystemCapability.Applications.Settings.Core 294 295**Required permissions**: 296- ohos.permission.MANAGE_SETTINGS for writing the DEVICE_SHARED and USER_PROPERTY fields (available only to system applications); 297- ohos.permission.MANAGE_SECURE_SETTINGS for writing the USER_SECURITY field (available only to system applications) 298 299**Parameters** 300 301| Name | Type | Mandatory| Description | 302| -------- | ---------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 303| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md). | 304| 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 | 305| value | string | Yes | Value of the data item. The value range varies by service. | 306|domainName| string | Yes | Domain name to set.<br>- **domainName.DEVICE_SHARED**:<br> shared device domain<br>- **domainName.USER_PROPERTY**:<br> user property domain<br>- **domainName.USER_SECURITY**:<br> user security domain (for system applications only)| 307 308**Return value** 309 310| Type | Description | 311|-------------------|---------------------------------------| 312| Promise\<boolean> | Promise used to return the result. The value **true** means that the operation is successful, and **false** means the opposite.| 313 314**Error codes** 315 316For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 317 318| ID| Error Message| 319| ------- | -------- | 320| 201 | Permission denied. | 321 322**Example** 323 324<!--code_no_check--> 325```js 326import { settings } from '@kit.BasicServicesKit'; 327import { common } from '@kit.AbilityKit'; 328 329// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValue API will update its value.) 330// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 331const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 332settings.setValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED).then((status) => { 333 console.log(`callback:return whether value is set.`) 334}); 335``` 336 337## settings.getValue<sup>10+</sup> 338 339getValue(context: Context, name: string, callback: AsyncCallback\<string>): void 340 341Obtains the value of a data item in the **DEVICE_SHARD** domain of the database. This API uses an asynchronous callback to return the result. 342 343**Model restriction**: This API can be used only in the stage model. 344 345**System capability**: SystemCapability.Applications.Settings.Core 346 347**Parameters** 348 349| Name | Type | Mandatory| Description | 350| -------- | ---------------------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------| 351| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 352| 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 | 353| callback | AsyncCallback\<string> | Yes | Callback used to return the value of the data item. | 354 355**Example** 356 357<!--code_no_check--> 358```js 359import { settings } from '@kit.BasicServicesKit'; 360import { common } from '@kit.AbilityKit'; 361 362// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 363const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 364settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, (err, value) => { 365 if (err) { 366 console.error(`Failed to get the setting. ${err.message} `); 367 return; 368 } 369 console.log(`callback:value -> ${value}`) 370}); 371``` 372 373## settings.getValue<sup>10+</sup> 374 375getValue(context: Context, name: string): Promise\<string> 376 377Obtains the value of a data item in the **DEVICE_SHARD** domain of the database. This API uses a promise to return the result. 378 379**Model restriction**: This API can be used only in the stage model. 380 381**System capability**: SystemCapability.Applications.Settings.Core 382 383**Parameters** 384 385| Name | Type | Mandatory| Description | 386| ------- | ------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------| 387| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 388| 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 | 389 390**Return value** 391 392| Type | Description | 393| ---------------- | ----------------------------------- | 394| Promise\<string> | Promise used to return the result.| 395 396**Example** 397 398<!--code_no_check--> 399```js 400import { settings } from '@kit.BasicServicesKit'; 401import { common } from '@kit.AbilityKit'; 402 403// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 404const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 405settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value) => { 406 console.log(`promise:value -> ${value}`) 407}); 408``` 409 410## settings.getValue<sup>11+</sup> 411 412getValue(context: Context, name: string, domainName: string): Promise\<string> 413 414Obtains the value of a data item in the database. This API uses a promise to return the result. 415 416**Model restriction**: This API can be used only in the stage model. 417 418**System capability**: SystemCapability.Applications.Settings.Core 419 420**Required permissions**: 421- ohos.permission.MANAGE_SECURE_SETTINGS for reading the USER_SECURITY field (available only to system applications) 422 423**Parameters** 424 425| Name | Type | Mandatory| Description | 426| -------- | ---------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 427| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md). | 428| 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 | 429|domainName| string | Yes | Domain name to set.<br>- **domainName.DEVICE_SHARED**:<br> shared device domain<br>- **domainName.USER_PROPERTY**:<br> user property domain<br>- **domainName.USER_SECURITY**:<br> user security domain (for system applications only)| 430 431**Return value** 432 433| Type | Description | 434| ---------------- | ----------------------------------- | 435| Promise\<string> | Promise used to return the result.| 436 437**Example** 438 439<!--code_no_check--> 440```js 441import { settings } from '@kit.BasicServicesKit'; 442import { common } from '@kit.AbilityKit'; 443 444// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the getValue API will update its value.) 445// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 446const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 447settings.getValue(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED).then((value) => { 448 console.log(`Promise:value -> ${value}`); 449}); 450``` 451 452## settings.getValueSync<sup>10+</sup> 453 454getValueSync(context: Context, name: string, defValue: string): string 455 456Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously. 457 458**Model restriction**: This API can be used only in the stage model. 459 460**System capability**: SystemCapability.Applications.Settings.Core 461 462**Parameters** 463 464| Name | Type | Mandatory| Description | 465| -------- | ------- | ---- |-------------------------------------------------------------------------------------------------------------------------------------------| 466| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 467| 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 | 468| 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. | 469 470**Return value** 471 472| Type | Description | 473| ------ | ---------------- | 474| string | Value of the data item.| 475 476**Example** 477 478<!--code_no_check--> 479```js 480import { settings } from '@kit.BasicServicesKit'; 481import { common } from '@kit.AbilityKit'; 482 483// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database). 484// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 485const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 486let value = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10'); 487``` 488 489## settings.getValueSync<sup>11+</sup> 490 491getValueSync(context: Context, name: string, defValue: string, domainName: string): string 492 493Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously. 494 495**Model restriction**: This API can be used only in the stage model. 496 497**System capability**: SystemCapability.Applications.Settings.Core 498 499**Required permissions**: 500- ohos.permission.MANAGE_SECURE_SETTINGS for reading the USER_SECURITY field (available only to system applications) 501 502**Parameters** 503 504| Name | Type | Mandatory| Description | 505|------------| ---------------------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 506| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md). | 507| 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 | 508| 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. | 509| domainName | string | Yes | Domain name to set.<br>- **domainName.DEVICE_SHARED**:<br> shared device domain<br>- **domainName.USER_PROPERTY**:<br> user property domain<br>- **domainName.USER_SECURITY**:<br> user security domain (for system applications only)| 510 511 512**Return value** 513 514| Type | Description | 515| ---------------- | ----------------------------------- | 516| string | Value of the data item. | 517 518**Example** 519 520<!--code_no_check--> 521```js 522import { settings } from '@kit.BasicServicesKit'; 523import { common } from '@kit.AbilityKit'; 524 525// Update the value of .SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database). 526// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 527const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 528let value = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED); 529``` 530 531## settings.setValueSync<sup>10+</sup> 532 533setValueSync(context: Context, name: string, value: string): boolean 534 535Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously. 536 537- If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. 538- If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. 539 540**Model restriction**: This API can be used only in the stage model. 541 542**System capability**: SystemCapability.Applications.Settings.Core 543 544**Required permissions**: ohos.permission.MANAGE_SETTINGS (available only to system applications) 545 546**Parameters** 547 548| Name | Type | Mandatory| Description | 549| ------- | ------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------| 550| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 551| 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 | 552| value | string | Yes | Value of the data item. The value range varies by service. | 553 554**Return value** 555 556| Type | Description | 557| ------- | ------------------------------------------------------------ | 558| boolean | Result indicating whether the value is set successfully. Returns **true** if the operation is successful; returns **false** otherwise.| 559 560**Example** 561 562<!--code_no_check--> 563```js 564import { settings } from '@kit.BasicServicesKit'; 565import { common } from '@kit.AbilityKit'; 566 567// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update its value.) 568// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 569const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 570let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100'); 571``` 572 573## settings.setValueSync<sup>11+</sup> 574 575setValueSync(context: Context, name: string, value: string, domainName: string): boolean 576 577Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously. 578 579- If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. 580- If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. 581 582**Model restriction**: This API can be used only in the stage model. 583 584**System capability**: SystemCapability.Applications.Settings.Core 585 586**Required permissions**: 587- ohos.permission.MANAGE_SETTINGS for writing the DEVICE_SHARED and USER_PROPERTY fields (available only to system applications); 588- ohos.permission.MANAGE_SECURE_SETTINGS for writing the USER_SECURITY field (available only to system applications) 589 590**Parameters** 591 592| Name | Type | Mandatory| Description | 593|---------| ---------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 594| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md). | 595| 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 | 596| value | string | Yes | Value of the data item. The value range varies by service. | 597| domainName | string | Yes | Domain name to set.<br>- **domainName.DEVICE_SHARED**:<br> shared device domain<br>- **domainName.USER_PROPERTY**:<br> user property domain<br>- **domainName.USER_SECURITY**:<br> user security domain (for system applications only)| 598 599**Return value** 600 601| Type | Description | 602| ---------------- | ----------------------------------- | 603| boolean | Result indicating whether the value is set successfully. Returns **true** if the operation is successful; returns **false** otherwise.| 604 605**Error codes** 606 607For details about the error codes, see [Universal Error Codes](../errorcode-universal.md). 608 609| ID| Error Message| 610| ------- | -------- | 611| 201 | Permission denied. | 612 613**Example** 614 615<!--code_no_check--> 616```js 617import { settings } from '@kit.BasicServicesKit'; 618import { common } from '@kit.AbilityKit'; 619 620// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update its value.) 621// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 622const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 623let ret = settings.setValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '100', settings.domainName.DEVICE_SHARED); 624``` 625 626## settings.registerKeyObserver<sup>11+</sup> 627 628registerKeyObserver(context: Context, name: string, domainName: string, observer:AsyncCallback\<void>): boolean 629 630Registers 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. Returns **true** if the operation is successful; returns **false** otherwise. 631 632**Model restriction**: This API can be used only in the stage model. 633 634**System capability**: SystemCapability.Applications.Settings.Core 635 636**Parameters** 637 638| Name | Type | Mandatory| Description | 639| -------- | ---------------------- | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 640| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md). | 641| 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 | 642|domainName| string | Yes | Domain name to set.<br>- **domainName.DEVICE_SHARED**:<br> shared device domain<br>- **domainName.USER_PROPERTY**:<br> user property domain<br>- **domainName.USER_SECURITY**:<br> user security domain (for system applications only)| 643|observer | AsyncCallback\<void> | Yes | Callback used to return the value of the data item. | 644 645**Return value** 646 647| Type | Description | 648| ---------------- |----------------------------------------| 649| boolean | Result indicating whether an observer is successfully registered. Returns **true** if the operation is successful; returns **false** otherwise.| 650 651**Example** 652 653<!--code_no_check--> 654```js 655import { settings } from '@kit.BasicServicesKit'; 656import { common } from '@kit.AbilityKit'; 657 658// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 659const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 660settings.registerKeyObserver(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED, () => { 661 let value:string = settings.getValueSync(context, settings.display.SCREEN_BRIGHTNESS_STATUS, '10'); 662 console.log(`Promise:value -> ${value}`); 663}); 664``` 665 666## settings.unregisterKeyObserver<sup>11+</sup> 667 668unregisterKeyObserver(context: Context, name: string, domainName: string): boolean 669 670Unregisters the observer under the specified domain name. This API returns the result synchronously. 671 672**Model restriction**: This API can be used only in the stage model. 673 674**System capability**: SystemCapability.Applications.Settings.Core 675 676**Parameters** 677 678| Name | Type | Mandatory| Description | 679| -------- | ---------------------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 680| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md). | 681| 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 | 682|domainName| string | Yes | Domain name to set.<br>- **domainName.DEVICE_SHARED**:<br> shared device domain<br>- **domainName.USER_PROPERTY**:<br> user property domain<br>- **domainName.USER_SECURITY**:<br> user security domain (for system applications only)| 683 684**Return value** 685 686| Type | Description | 687| ---------------- | ----------------------------------- | 688| boolean | Result indicating whether the observer under the specified domain name is successfully unregistered. Returns **true** if the operation is successful; returns **false** otherwise.| 689 690**Example** 691 692<!--code_no_check--> 693```js 694import { settings } from '@kit.BasicServicesKit'; 695import { common } from '@kit.AbilityKit'; 696 697// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 698const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 699let ret = settings.unregisterKeyObserver(context, settings.display.SCREEN_BRIGHTNESS_STATUS, settings.domainName.DEVICE_SHARED); 700``` 701 702## settings.openNetworkManagerSettings<sup>18+</sup> 703 704openNetworkManagerSettings(context: Context): Promise\<boolean> 705 706Opens the network manager settings page. This API uses a promise to return the result. 707 708**Atomic service API**: This API can be used in atomic services since API version 18. 709 710**System capability**: SystemCapability.Applications.Settings.Core 711 712**Parameters** 713 714| Name | Type | Mandatory| Description | 715| -------- | ---------------------- | ---- |--------------------------------------------------------------------------------------------------------------------------------------------| 716| context | Context | Yes | Application context. Only UIAbilityContext and ExtensionContext are supported.<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-context.md).| 717 718**Return value** 719 720| Type | Description | 721| ---------------- |---------------------------------------| 722| Promise\<boolean> | Promise used to return the result. The value **true** means that the operation is successful, and **false** means the opposite.| 723 724**Error codes** 725 726For details about the error codes, see [Settings Error Codes](./errorcode-settings.md). 727 728| ID | Error Message | 729|----------|-------------------------| 730| 14800000 | Parameter error. | 731| 14800010 | Original service error. | 732 733**Example** 734 735<!--code_no_check--> 736```js 737import { settings } from '@kit.BasicServicesKit'; 738import { common } from '@kit.AbilityKit'; 739 740// Redirect to the network manager settings page. 741// Obtain the context from the component and ensure that the return value of this.getUIContext().getHostContext() is UIAbilityContext. 742const context: Context = this.getUIContext().getHostContext() as common.UIAbilityContext; 743settings.openNetworkManagerSettings(context).then((status) => { 744 console.log(`callback:return whether settings is open.`) 745}); 746``` 747 748## settings.enableAirplaneMode 749 750enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void 751 752Enables or disables airplane mode. This API uses an asynchronous callback to return the result. (Not supported yet.) 753 754**System capability**: SystemCapability.Applications.Settings.Core 755 756**Parameters** 757 758| Name | Type | Mandatory| Description | 759| -------- | -------------------- | ---- | ----------------------------------------------- | 760| enable | boolean | Yes | Whether airplane mode is enabled. The value **true** means that airplane mode is enabled, and **false** means the opposite.| 761| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | 762 763**Example** 764 765```js 766let isEnabled :boolean = true; 767settings.enableAirplaneMode(isEnabled, (err:Error) => { 768 if (err) { 769 console.error('Failed to enable AirplaneMode.'); 770 return; 771 } 772 console.log('Return true if enable.'); 773}) 774``` 775 776## settings.enableAirplaneMode 777 778enableAirplaneMode(enable: boolean): Promise\<void> 779 780Enables or disables airplane mode. This API uses a promise to return the result. (Not supported yet.) 781 782**System capability**: SystemCapability.Applications.Settings.Core 783 784**Parameters** 785 786| Name| Type | Mandatory| Description | 787| ------ | ------- | ---- | ----------------------------------------------- | 788| enable | boolean | Yes | Whether airplane mode is enabled. The value **true** means that airplane mode is enabled, and **false** means the opposite.| 789 790**Return value** 791 792| Type | Description | 793| -------------- | ------------------------- | 794| Promise\<void> | Promise that returns no value.| 795 796**Example** 797 798```js 799let isEnabled :boolean = true; 800settings.enableAirplaneMode(isEnabled).then(() => { 801 console.log('Succeeded in enabling AirplaneMode.'); 802}).catch((err:Error) => { 803 console.error(`Failed to enable AirplaneMode. Cause: ${err}`); 804}) 805``` 806 807## settings.canShowFloating 808 809canShowFloating(callback: AsyncCallback\<boolean>): void 810 811Checks whether the application can be displayed in a floating window. This API uses an asynchronous callback to return the result. (Not supported yet.) 812 813**System capability**: SystemCapability.Applications.Settings.Core 814 815**Parameters** 816 817| Name | Type | Mandatory| Description | 818| -------- | ----------------------- | ---- | ------------------------------------------------------------ | 819| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>The value **true** means that the application can be displayed in a floating window, and **false** means the opposite.| 820 821**Example** 822 823```js 824settings.canShowFloating((err:Error, status: boolean) => { 825 if (err) { 826 console.error(`Failed to Checks whether a specified application can show as float window ${err.message} `); 827 return; 828 } 829 console.log('Checks whether a specified application can show as float window.'); 830}); 831``` 832 833## settings.canShowFloating 834 835canShowFloating(): Promise\<boolean> 836 837Checks whether the application can be displayed in a floating window. This API uses a promise to return the result. (Not supported yet.) 838 839**System capability**: SystemCapability.Applications.Settings.Core 840 841**Return value** 842 843| Type | Description | 844| ----------------- | ------------------------------------------------------------ | 845| Promise\<boolean> | Promise used to return the result.<br>The value **true** means that the application can be displayed in a floating window, and **false** means the opposite.| 846 847**Example** 848 849```js 850settings.canShowFloating().then((status:boolean) => { 851 console.log('Checks whether a specified application can show as float window.'); 852}); 853``` 854 855## settings.getUriSync<sup>8+</sup> 856 857getUriSync(name: string): string 858 859Obtains the URI of a data item. (Not supported yet.) 860 861**System capability**: SystemCapability.Applications.Settings.Core 862 863**Parameters** 864 865| Name| Type | Mandatory| Description | 866| ------ | ------ | ---- |---------------------------------------------------------------| 867| name | string | Yes | Name of the target data item. Data items can be classified as follows:<br>- Existing data items in the database<br>- Custom data items| 868 869**Return value** 870 871| Type | Description | 872| ------ | ------------- | 873| string | URI of the data item.| 874 875**Example** 876 877```js 878// Obtain the URI of a data item. 879let uriVar:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 880``` 881 882## settings.getURI<sup>(deprecated)</sup> 883 884getURI(name: string, callback: AsyncCallback\<object>): void 885 886Obtains the URI of a data item. This API uses an asynchronous callback to return the result. (Not supported yet.) 887 888> **NOTE** 889> 890> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided. 891 892**System capability**: SystemCapability.Applications.Settings.Core 893 894**Parameters** 895 896| Name | Type | Mandatory| Description | 897| -------- | ---------------------- | ---- |---------------------------------------------------------------| 898| 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| 899| callback | AsyncCallback\<object> | Yes | Callback used to return the result. Obtains the URI of a data item. | 900 901**Example** 902 903```js 904settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS, (uri:string) => { 905 console.log(`callback:uri -> ${JSON.stringify(uri)}`) 906}) 907``` 908 909## settings.getURI<sup>(deprecated)</sup> 910 911getURI(name: string): Promise\<object> 912 913Obtains the URI of a data item. This API uses a promise to return the result. (Not supported yet.) 914 915> **NOTE** 916> 917> This API is supported since API version 7 and deprecated since API version 9. No substitute API is provided. 918 919**System capability**: SystemCapability.Applications.Settings.Core 920 921**Parameters** 922 923| Name| Type | Mandatory| Description | 924| ------ | ------ | ---- |---------------------------------------------------------------| 925| 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| 926 927**Return value** 928 929| Type | Description | 930| ---------------- | ------------------------------------ | 931| Promise\<object> | Promise used to return the result.| 932 933**Example** 934 935```js 936settings.getURI(settings.display.SCREEN_BRIGHTNESS_STATUS).then((uri:string) => { 937 console.log(`promise:uri -> ${JSON.stringify(uri)}`) 938}) 939``` 940 941 942 943## settings.getValue<sup>(deprecated)</sup> 944 945getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCallback\<object>): void 946 947Obtains the value of a data item in the **DEVICE_SHARD** domain of the database. This API uses an asynchronous callback to return the result. 948 949> **NOTE** 950> 951> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settingsgetvalue10) instead. 952 953**Model restriction**: This API can be used only in the FA model. 954 955**System capability**: SystemCapability.Applications.Settings.Core 956 957**Parameters** 958 959| Name | Type | Mandatory| Description | 960| ----------------- | ------------------------------------------------------------ | ---- |---------------------------------------------------------------| 961| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 962| 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| 963| callback | AsyncCallback\<object> | Yes | Callback used to return the value of the data item. | 964 965**Example** 966 967```js 968import featureAbility from '@ohos.ability.featureAbility'; 969 970let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 971let helper = featureAbility.acquireDataAbilityHelper(uri); 972settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, (err:Error, value:string) => { 973 if (err) { 974 console.error(`Failed to get the setting. ${err.message} `); 975 return; 976 } 977 console.log(`callback:value -> ${JSON.stringify(value)}`) 978}); 979``` 980 981## settings.getValue<sup>(deprecated)</sup> 982 983getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object> 984 985Obtains the value of a data item in the **DEVICE_SHARD** domain of the database. This API uses a promise to return the result. 986 987> **NOTE** 988> 989> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [getValue()](#settingsgetvalue10-1) instead. 990 991**Model restriction**: This API can be used only in the FA model. 992 993**System capability**: SystemCapability.Applications.Settings.Core 994 995**Parameters** 996 997| Name | Type | Mandatory| Description | 998| ----------------- | ------------------------------------------------------------ | ---- |---------------------------------------------------------------| 999| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 1000| 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| 1001 1002**Return value** 1003 1004| Type | Description | 1005| ---------------- |-----------------------| 1006| Promise\<object> | Promise used to return the result.| 1007 1008**Example** 1009 1010```js 1011import featureAbility from '@ohos.ability.featureAbility'; 1012 1013let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 1014let helper = featureAbility.acquireDataAbilityHelper(uri); 1015settings.getValue(helper, settings.display.SCREEN_BRIGHTNESS_STATUS).then((value:string) => { 1016 console.log(`promise:value -> ${JSON.stringify(value)}`) 1017}); 1018``` 1019 1020## settings.getValueSync<sup>(deprecated)</sup> 1021 1022getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: string): string 1023 1024Obtains the value of a data item. Unlike **getValue**, this API returns the result synchronously. 1025 1026> **NOTE** 1027> 1028> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [getValueSync()](#settingsgetvaluesync10) instead. 1029 1030**Model restriction**: This API can be used only in the FA model. 1031 1032**System capability**: SystemCapability.Applications.Settings.Core 1033 1034**Parameters** 1035 1036| Name | Type | Mandatory| Description | 1037| ----------------- | ------------------------------------------------------------ | ---- |--------------------------------------------------------------| 1038| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 1039| 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| 1040| 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. | 1041 1042**Return value** 1043 1044| Type | Description | 1045| ------ | ---------------- | 1046| string | Value of the data item.| 1047 1048**Example** 1049 1050```js 1051import featureAbility from '@ohos.ability.featureAbility'; 1052 1053// Obtain the value of SCREEN_BRIGHTNESS_STATUS (this data item already exists in the database). 1054let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 1055let helper = featureAbility.acquireDataAbilityHelper(uri); 1056let value:string = settings.getValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '10'); 1057``` 1058 1059## settings.setValueSync<sup>(deprecated)</sup> 1060 1061setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean 1062 1063Sets the value for a data item. Unlike **setValue**, this API returns the result synchronously. 1064 1065- If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. 1066- If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. 1067 1068> **NOTE** 1069> 1070> This API is supported since API version 8 and deprecated since API version 9. You are advised to use [setValueSync()](#settingssetvaluesync10) instead. 1071 1072**Model restriction**: This API can be used only in the FA model. 1073 1074**Required permissions**: ohos.permission.MANAGE_SETTINGS (available only to system applications) 1075 1076**System capability**: SystemCapability.Applications.Settings.Core 1077 1078**Parameters** 1079 1080| Name | Type | Mandatory| Description | 1081| ----------------- | ------------------------------------------------------------ | ---- |---------------------------------------------------------------| 1082| dataAbilityHelper | [DataAbilityHelper](../apis-ability-kit/js-apis-inner-ability-dataAbilityHelper.md) | Yes | **DataAbilityHelper** class. | 1083| 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| 1084| value | string | Yes | Value of the data item. The value range varies by service. | 1085 1086**Return value** 1087 1088| Type | Description | 1089| ------- | ------------------------------------------------------------ | 1090| boolean | Result indicating whether the value is set successfully. Returns **true** if the operation is successful; returns **false** otherwise.| 1091 1092**Example** 1093 1094```js 1095import featureAbility from '@ohos.ability.featureAbility'; 1096 1097// Update the value of SCREEN_BRIGHTNESS_STATUS. (As this data item exists in the database, the setValueSync API will update its value.) 1098let uri:string = settings.getUriSync(settings.display.SCREEN_BRIGHTNESS_STATUS); 1099let helper = featureAbility.acquireDataAbilityHelper(uri); 1100let ret:string = settings.setValueSync(helper, settings.display.SCREEN_BRIGHTNESS_STATUS, '100'); 1101``` 1102