harmony 鸿蒙oh_preferences.h
oh_preferences.h
Overview
Provides APIs and structs for accessing the Preferences object.
File to include: <database/preferences/oh_preferences.h>
Library: libohpreferences.so
System capability: SystemCapability.DistributedDataManager.Preferences.Core
Since: 13
Related module: Preferences
Summary
Types
Name | Description |
---|---|
typedef struct OH_Preferences OH_Preferences | Defines a Preferences object. |
typedef void(* OH_PreferencesDataObserver) (void *context, const OH_PreferencesPair *pairs, uint32_t count) | Defines the callback to be invoked when data changes. |
Functions
Name | Description |
---|---|
OH_Preferences * OH_Preferences_Open (OH_PreferencesOption *option, int *errCode) | Opens a Preferences instance and creates a pointer to it. If this pointer is no longer required, use OH_Preferences_Close to close the instance. |
int OH_Preferences_Close (OH_Preferences *preference) | Closes a Preferences instance. |
int OH_Preferences_GetInt (OH_Preferences *preference, const char *key, int *value) | Obtains an integer corresponding to the specified key in a Preferences instance. |
int OH_Preferences_GetBool (OH_Preferences *preference, const char *key, bool *value) | Obtains a Boolean value corresponding to the specified key in a Preferences instance. |
int OH_Preferences_GetString (OH_Preferences *preference, const char *key, char **value, uint32_t *valueLen) | Obtains a string corresponding to the specified key in a Preferences instance. |
void OH_Preferences_FreeString (char *string) | Releases a string. |
int OH_Preferences_SetInt (OH_Preferences *preference, const char *key, int value) | Sets an integer value based on the specified key in a Preferences instance. |
int OH_Preferences_SetBool (OH_Preferences *preference, const char *key, bool value) | Sets a Boolean value based on the specified key in a Preferences instance. |
int OH_Preferences_SetString (OH_Preferences *preference, const char *key, const char *value) | Sets a string based on the specified key in a Preferences instance. |
int OH_Preferences_Delete (OH_Preferences *preference, const char *key) | Deletes a KV pair of the specified key from a Preferences object. |
int OH_Preferences_RegisterDataObserver (OH_Preferences *preference, void *context, OH_PreferencesDataObserver observer, const char *keys[], uint32_t keyCount) | Subscribes to data changes of the specified key. If the value of the specified key changes, a callback will be invoked after OH_Preferences_Close () is called. |
int OH_Preferences_UnregisterDataObserver (OH_Preferences *preference, void *context, OH_PreferencesDataObserver observer, const char *keys[], uint32_t keyCount) | Unsubscribes from data changes of the specified key. |
int OH_Preferences_IsStorageTypeSupported (Preferences_StorageType type, bool *isSupported) | Checks whether the specified storage type is supported. |
你可能感兴趣的鸿蒙文章
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦