harmony 鸿蒙udmf.h

  • 2025-06-12
  • 浏览 (6)

udmf.h

Overview

Defines the APIs, data structs, and enums for accessing the UDMF.

File to include: <database/udmf/udmf.h>

Library: libudmf.so

System capability: SystemCapability.DistributedDataManager.UDMF.Core

Since: 12

Related module: UDMF

Summary

Macros

Name Description
UDMF_KEY_BUFFER_LEN   (512) Minimum length of the buffer that holds the key (unique identifier) of a uniform data object.

Types

Name Description
typedef enum Udmf_Intention Udmf_Intention Defines an enum for UDMF data channel types.
typedef enum Udmf_ShareOption Udmf_ShareOption Defines an enum for the scopes of the uniform data to be used on a device.
typedef enum Udmf_FileConflictOptions Udmf_FileConflictOptions Defines an enum for the options used to resolve file copy conflicts.
typedef enum Udmf_ProgressIndicator Udmf_ProgressIndicator Defines an enum for the progress indicator options.
typedef struct OH_UdmfData OH_UdmfData Defines a struct for a uniform data object.
typedef struct OH_UdmfRecord OH_UdmfRecord Defines a struct for a data record in a uniform data object.
typedef struct OH_UdmfRecordProvider OH_UdmfRecordProvider Defines a struct for the data record provider in a uniform data object.
typedef struct OH_UdmfProperty OH_UdmfProperty Defines a struct for a data record property in a uniform data object.
typedef struct OH_Udmf_ProgressInfo OH_Udmf_ProgressInfo Defines a struct for progress information.
typedef struct OH_UdmfGetDataParams OH_UdmfGetDataParams Defines a struct for parameters used to obtain UDMF data asynchronously.
typedef void(* OH_Udmf_DataProgressListener) (OH_Udmf_ProgressInfo *progressInfo, OH_UdmfData *data) Defines the callback used to return the data retrieval progress information and data obtained.
A null pointer is returned if the progress is not 100. The data obtained is returned only when the progress reaches 100.
typedef void(* UdmfData_Finalize) (void *context) Defines a callback function used to release the context. This callback is invoked when the OH_UdmfRecordProvider instance is destroyed.
typedef void *(* OH_UdmfRecordProvider_GetData) (void *context, const char *type) Defines a callback function used to obtain data by type. This callback is invoked when data is obtained from OH_UdmfRecord. It returns the data obtained.

Enums

Name Description
Udmf_Intention { UDMF_INTENTION_DRAG, UDMF_INTENTION_PASTEBOARD } Enumerates the UDMF data channel types.
Udmf_ShareOption { SHARE_OPTIONS_INVALID, SHARE_OPTIONS_IN_APP, SHARE_OPTIONS_CROSS_APP } Enumerates the scopes of the uniform data to be used on a device.
Udmf_FileConflictOptions { UDMF_OVERWRITE = 0, UDMF_SKIP = 1 } Enumerates the options used to resolve file copy conflicts.
Udmf_ProgressIndicator { UDMF_NONE = 0, UDMF_DEFAULT = 1 } Enumerates the progress indicator options.

Functions

Name Description
OH_UdmfData * OH_UdmfData_Create () Creates an OH_UdmfData instance and a pointer to it. If this pointer is no longer required, use OH_UdmfData_Destroy to destroy it. Otherwise, memory leaks may occur.
void OH_UdmfData_Destroy (OH_UdmfData *pThis) Destroys an OH_UdmfData instance.
int OH_UdmfData_AddRecord (OH_UdmfData *pThis, OH_UdmfRecord *record) Adds an OH_UdmfRecord to an OH_UdmfData instance.
bool OH_UdmfData_HasType (OH_UdmfData *pThis, const char *type) Checks whether the specified type exists in an OH_UdmfData instance.
char ** OH_UdmfData_GetTypes (OH_UdmfData *pThis, unsigned int *count) Obtains all data types in an OH_UdmfData instance.
OH_UdmfRecord ** OH_UdmfData_GetRecords (OH_UdmfData *pThis, unsigned int *count) Obtains all records contained in an OH_UdmfData instance.
OH_UdmfRecordProvider * OH_UdmfRecordProvider_Create () Creates an OH_UdmfRecordProvider instance. If this pointer is no longer required, use OH_UdmfRecordProvider_Destroy to destroy it. Otherwise, memory leaks may occur.
int OH_UdmfRecordProvider_Destroy (OH_UdmfRecordProvider *provider) Destroys an OH_UdmfRecordProvider instance.
int OH_UdmfRecordProvider_SetData (OH_UdmfRecordProvider *provider, void *context, const OH_UdmfRecordProvider_GetData callback, const UdmfData_Finalize finalize) Sets a callback for an OH_UdmfRecordProvider instance to provide data.
OH_UdmfRecord * OH_UdmfRecord_Create () Creates an OH_UdmfRecord instance and a pointer to it. If this pointer is no longer required, use OH_UdmfRecord_Destroy to destroy it. Otherwise, memory leaks may occur.
void OH_UdmfRecord_Destroy (OH_UdmfRecord *pThis) Destroys an OH_UdmfRecord instance.
int OH_UdmfRecord_AddGeneralEntry (OH_UdmfRecord *pThis, const char *typeId, unsigned char *entry, unsigned int count) Adds customized uniform data to an OH_UdmfRecord instance. This API cannot be used to add data of UDS types (such as PlainText, Link, and Pixelmap).
int OH_UdmfRecord_AddPlainText (OH_UdmfRecord *pThis, OH_UdsPlainText *plainText) Adds data of the OH_UdsPlainText type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddHyperlink (OH_UdmfRecord *pThis, OH_UdsHyperlink *hyperlink) Adds data of the hyperlink type OH_UdsHyperlink type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddHtml (OH_UdmfRecord *pThis, OH_UdsHtml *html) Adds data of the OH_UdsHtml type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddAppItem (OH_UdmfRecord *pThis, OH_UdsAppItem *appItem) Adds data of the OH_UdsAppItem type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddFileUri (OH_UdmfRecord *pThis, OH_UdsFileUri *fileUri) Adds a data record of the OH_UdsFileUri type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddPixelMap (OH_UdmfRecord *pThis, OH_UdsPixelMap *pixelMap) Adds a data record of the OH_UdsPixelMap type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddArrayBuffer (OH_UdmfRecord *record, const char *type, OH_UdsArrayBuffer *buffer) Adds a data record of the OH_UdsArrayBuffer type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddContentForm (OH_UdmfRecord *pThis, OH_UdsContentForm *contentForm) Adds data of the OH_UdsContentForm type to an OH_UdmfRecord instance.
char ** OH_UdmfRecord_GetTypes (OH_UdmfRecord *pThis, unsigned int *count) Obtains all data types in an OH_UdmfRecord instance.
int OH_UdmfRecord_GetGeneralEntry (OH_UdmfRecord *pThis, const char *typeId, unsigned char **entry, unsigned int *count) Obtains the data of the specified type in an OH_UdmfRecord instance.
int OH_UdmfRecord_GetPlainText (OH_UdmfRecord *pThis, OH_UdsPlainText *plainText) Obtains OH_UdsPlainText data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetHyperlink (OH_UdmfRecord *pThis, OH_UdsHyperlink *hyperlink) Obtains OH_UdsHyperlink data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetHtml (OH_UdmfRecord *pThis, OH_UdsHtml *html) Obtains OH_UdsHtml data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetAppItem (OH_UdmfRecord *pThis, OH_UdsAppItem *appItem) Obtains OH_UdsAppItem data from an OH_UdmfRecord instance.
int OH_UdmfRecord_SetProvider (OH_UdmfRecord *pThis, const char *const *types, unsigned int count, OH_UdmfRecordProvider *provider) Sets the OH_UdmfRecordProvider in an OH_UdmfRecord instance.
int OH_UdmfRecord_GetFileUri (OH_UdmfRecord *pThis, OH_UdsFileUri *fileUri) Obtains the OH_UdsFileUri data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetPixelMap (OH_UdmfRecord *pThis, OH_UdsPixelMap *pixelMap) Obtains the OH_UdsPixelMap data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetArrayBuffer (OH_UdmfRecord *record, const char *type, OH_UdsArrayBuffer *buffer) Obtains the OH_UdsArrayBuffer data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetContentForm (OH_UdmfRecord *pThis, OH_UdsContentForm *contentForm) Obtains data of the OH_UdsContentForm type from an OH_UdmfRecord instance.
int OH_UdmfData_GetPrimaryPlainText (OH_UdmfData *data, OH_UdsPlainText *plainText) Obtains the first OH_UdsPlainText data from an OH_UdmfData instance.
int OH_UdmfData_GetPrimaryHtml (OH_UdmfData *data, OH_UdsHtml *html) Obtains the first OH_UdsHtml data from an OH_UdmfData instance.
int OH_UdmfData_GetRecordCount (OH_UdmfData *data) Obtains the number of data records contained in an OH_UdmfData instance.
OH_UdmfRecord * OH_UdmfData_GetRecord (OH_UdmfData *data, unsigned int index) Obtains the specified data record from an OH_UdmfData instance.
bool OH_UdmfData_IsLocal (OH_UdmfData *data) Checks whether an OH_UdmfData instance is from the local device.
OH_UdmfProperty * OH_UdmfProperty_Create (OH_UdmfData *unifiedData) Creates an OH_UdmfProperty instance and a pointer to it. If this pointer is no longer required, use OH_UdmfProperty_Destroy to destroy it. Otherwise, memory leaks may occur.
void OH_UdmfProperty_Destroy (OH_UdmfProperty *pThis) Destroys an OH_UdmfProperty instance.
const char * OH_UdmfProperty_GetTag (OH_UdmfProperty *pThis) Obtains the custom tag value from an OH_UdmfProperty instance.
int64_t OH_UdmfProperty_GetTimestamp (OH_UdmfProperty *pThis) Obtains the timestamp from an OH_UdmfProperty instance.
Udmf_ShareOption OH_UdmfProperty_GetShareOption (OH_UdmfProperty *pThis) Obtains the share option from an OH_UdmfProperty instance.
int OH_UdmfProperty_GetExtrasIntParam (OH_UdmfProperty *pThis, const char *key, int defaultValue) Obtains the customized extra integer parameter from an OH_UdmfProperty instance.
const char * OH_UdmfProperty_GetExtrasStringParam (OH_UdmfProperty *pThis, const char *key) Obtains the customized extra string parameter from an OH_UdmfProperty instance.
int OH_UdmfProperty_SetTag (OH_UdmfProperty *pThis, const char *tag) Sets the tag value for an OH_UdmfProperty instance.
int OH_UdmfProperty_SetShareOption (OH_UdmfProperty *pThis, Udmf_ShareOption option) Sets OH_Udmf_ShareOption for an OH_UdmfProperty instance.
int OH_UdmfProperty_SetExtrasIntParam (OH_UdmfProperty *pThis, const char *key, int param) Sets the extra integer parameter for an OH_UdmfProperty instance.
int OH_UdmfProperty_SetExtrasStringParam (OH_UdmfProperty *pThis, const char *key, const char *param) Sets the extra string parameter for an OH_UdmfProperty instance.
int OH_Udmf_GetUnifiedData (const char *key, Udmf_Intention intention, OH_UdmfData *unifiedData) Obtains an OH_UdmfData instance from the UDMF database.
int OH_Udmf_SetUnifiedData (Udmf_Intention intention, OH_UdmfData *unifiedData, char *key, unsigned int keyLen) Sets an OH_UdmfData instance in the UDMF database.
int OH_UdmfProgressInfo_GetProgress (OH_Udmf_ProgressInfo *progressInfo) Obtains the progress information from OH_Udmf_ProgressInfo.
int OH_UdmfProgressInfo_GetStatus (OH_Udmf_ProgressInfo *progressInfo) Obtains the status information from OH_Udmf_ProgressInfo.
OH_UdmfGetDataParams * OH_UdmfGetDataParams_Create () Creates an OH_UdmfGetDataParams instance for asynchronously obtaining UDMF data.
If this pointer is no longer required, use OH_UdmfGetDataParams_Destroy to destroy it. Otherwise, memory leaks may occur.
void OH_UdmfGetDataParams_Destroy (OH_UdmfGetDataParams *pThis) Destroys an OH_UdmfGetDataParams instance.
void OH_UdmfGetDataParams_SetDestUri (OH_UdmfGetDataParams *params, const char *destUri) Sets the destination directory in an OH_UdmfGetDataParams instance.
If the destination directory is set, data of the file type will be copied to the specified directory. The file type data obtained in the callback will be replaced with the URI of the destination directory.
If the destination directory is not specified, the file will not be copied. The file type data obtained in the callback is the URI of the source directory.
If the application involves complex file processing or files need to be copied to multiple directories, you are advised to leave this parameter unspecified and let the application to handle the file copy.
void OH_UdmfGetDataParams_SetFileConflictOptions (OH_UdmfGetDataParams *params, const Udmf_FileConflictOptions options) Sets the policy for resolving file conflicts in an OH_UdmfGetDataParams instance.
void OH_UdmfGetDataParams_SetProgressIndicator (OH_UdmfGetDataParams *params, const Udmf_ProgressIndicator progressIndicator) Sets the progress indicator in an OH_UdmfGetDataParams instance.
void OH_UdmfGetDataParams_SetDataProgressListener (OH_UdmfGetDataParams *params, const OH_Udmf_DataProgressListener dataProgressListener) Sets the callback used to return the data obtained in an OH_UdmfGetDataParams instance.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkData (ArkData Management)

harmony 鸿蒙Data

harmony 鸿蒙OH_Cursor

harmony 鸿蒙OH_Predicates

harmony 鸿蒙OH_Rdb_Config

harmony 鸿蒙OH_Rdb_Store

harmony 鸿蒙OH_VBucket

harmony 鸿蒙OH_VObject

harmony 鸿蒙Preferences

harmony 鸿蒙_r_d_b

0  赞