openharmony 鸿蒙 js-apis-settings-sys

2025-06-12 浏览 (1)

@ohos.settings (Data Item Settings) (System API)

The settings module provides APIs for setting data items.

NOTE

  • 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.
  • This topic describes only system APIs provided by the module. For details about its public APIs, see @ohos.settings (Data Item Settings).

Modules to Import

import settings from '@ohos.settings';

domainName

Provides the domain name.

Attributes

System capability: SystemCapability.Applications.Settings.Core

NameTypeReadableWritableDescription
USER_SECURITY11+stringYesYesUser security attribute domain.

settings.setValue(deprecated)

setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, callback: AsyncCallback<boolean>): void

Sets the value for a data item. This API uses an asynchronous callback to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. You are advised to use setValue() instead.

System API: This is a system API.

Model restriction: This API can be used only in the FA model.

System capability: SystemCapability.Applications.Settings.Core

Parameters

NameTypeMandatoryDescription
dataAbilityHelperDataAbilityHelperYesDataAbilityHelper class.
namestringYesName of the target data item. Data items can be classified as follows:
- Existing data items in the database
- Custom data items
valueobjectYesValue of the data item. The value range varies by service.
callbackAsyncCallback<boolean>YesCallback used to return the result. Returns true if the operation is successful; returns false otherwise.

settings.setValue(deprecated)

setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Promise<boolean>

Sets the value for a data item. This API uses a promise to return the result.

NOTE

This API is supported since API version 7 and deprecated since API version 9. You are advised to use setValue() instead.

System API: This is a system API.

Model restriction: This API can be used only in the FA model.

System capability: SystemCapability.Applications.Settings.Core

Parameters

NameTypeMandatoryDescription
dataAbilityHelperDataAbilityHelperYesDataAbilityHelper class.
namestringYesName of the target data item. Data items can be classified as follows:
- Existing data items in the database
- Custom data items
valueobjectYesValue of the data item. The value range varies by service.

Return value

TypeDescription
Promise<boolean>Promise used to return the result. Returns true if the operation is successful; returns false otherwise.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Basic Services Kit

harmony 鸿蒙DeviceInfo

harmony 鸿蒙InitSync

harmony 鸿蒙OH_Print

harmony 鸿蒙OsAccount

harmony 鸿蒙Pasteboard

harmony 鸿蒙Print_Margin

harmony 鸿蒙Print_PageSize

harmony 鸿蒙Print_PrintAttributes

harmony 鸿蒙Print_PrintDocCallback

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/hwjiBR