GGiteeupdate
1e210325创建于 2024年9月13日历史提交

oh_preferences_value.h

概述

提供访问Preferences值(PreferencesValue)对象的接口、枚举类型与数据结构。

引用文件:<database/preferences/oh_preferences_value.h>

库: libohpreferences.so

系统能力: SystemCapability.DistributedDataManager.Preferences.Core

起始版本: 13

相关模块:Preferences

汇总

类型定义

名称 描述
typedef enum Preference_ValueType Preference_ValueType 定义PreferencesValue的数据类型。
typedef struct OH_PreferencesPair OH_PreferencesPair 定义Preferences使用的KV数据对象类型。
typedef struct OH_PreferencesValue OH_PreferencesValue 定义PreferencesValue对象类型。

枚举

名称 描述
Preference_ValueType {
PREFERENCE_TYPE_NULL = 0, PREFERENCE_TYPE_INT, PREFERENCE_TYPE_BOOL, PREFERENCE_TYPE_STRING,
PREFERENCE_TYPE_BUTT
}
定义PreferencesValue的数据类型。

函数

名称 描述
const char * OH_PreferencesPair_GetKey (const OH_PreferencesPair *pairs, uint32_t index) 获取KV数据中索引对应数据的键。
const OH_PreferencesValue * OH_PreferencesPair_GetPreferencesValue (const OH_PreferencesPair *pairs, uint32_t index) 获取KV数据数组中索引对应的值。
Preference_ValueType OH_PreferencesValue_GetValueType (const OH_PreferencesValue *object) 获取PreferencesValue对象的数据类型。
int OH_PreferencesValue_GetInt (const OH_PreferencesValue *object, int *value) 从PreferencesValue对象OH_PreferencesValue中获取一个整型值。
int OH_PreferencesValue_GetBool (const OH_PreferencesValue *object, bool *value) 从PreferencesValue对象OH_PreferencesValue中获取一个布尔值。
int OH_PreferencesValue_GetString (const OH_PreferencesValue *object, char **value, uint32_t *valueLen) 从PreferencesValue对象OH_PreferencesValue中获取字符串。