openharmony 鸿蒙 capi-udmf-h

2026-08-25 浏览 (1)

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

Structs

Nametypedef KeywordDescription
OH_UdmfDataOH_UdmfDataDefines a struct for a unified data object.
OH_UdmfRecordOH_UdmfRecordDefines a struct for a data record in a unified data object.
OH_UdmfRecordProviderOH_UdmfRecordProviderDefines a struct for the data record provider in a unified data object.
OH_UdmfPropertyOH_UdmfPropertyDefines a struct for a data record property in a uniform data object.
OH_Udmf_ProgressInfoOH_Udmf_ProgressInfoDefines a struct for progress information.
OH_UdmfGetDataParamsOH_UdmfGetDataParamsDefines a struct for parameters used to obtain UDMF data asynchronously.
OH_UdmfOptionsOH_UdmfOptionsDefines the optional parameters for data operations.
OH_UdmfDataLoadParamsOH_UdmfDataLoadParamsDefines a struct for data loading parameters.
OH_UdmfDataLoadInfoOH_UdmfDataLoadInfoDefines a struct for the data loading information.

Enums

Nametypedef KeywordDescription
Udmf_IntentionUdmf_IntentionEnumerates the UDMF data channel types.
Udmf_ShareOptionUdmf_ShareOptionEnumerates the options for using the unified data in a device.
Udmf_FileConflictOptionsUdmf_FileConflictOptionsEnumerates the options used to resolve file copy conflicts.
Udmf_ProgressIndicatorUdmf_ProgressIndicatorEnumerates the progress indicator options. You can use the default progress indicator as required.
Udmf_VisibilityUdmf_VisibilityEnumerates data visibility level.

Functions

Nametypedef KeywordDescription
UDMF_KEY_BUFFER_LEN (512)-Defines minimum length of the buffer that holds the key (unique identifier) of a unified data object.
typedef void (*OH_Udmf_DataProgressListener)(OH_Udmf_ProgressInfo* progressInfo, OH_UdmfData* data)OH_Udmf_DataProgressListenerDefines the callback used to return the data retrieval progress information and data obtained.
A null pointer is returned if the progress is less than 100%. The data obtained is returned only when the progress reaches 100%.
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.
typedef void (*UdmfData_Finalize)(void* context)UdmfData_FinalizeDefines a callback function used to release the context. This callback is invoked when the OH_UdmfRecordProvider instance is destroyed.
OH_UdmfRecordProvider* OH_UdmfRecordProvider_Create()-Creates an OH_UdmfRecordProvider instance and a pointer to it. 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.
typedef void* (*OH_UdmfRecordProvider_GetData)(void* context, const char* type)OH_UdmfRecordProvider_GetDataDefines a callback function used to obtain data by type. This callback will be invoked to return the data obtained from OH_UdmfRecord.
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 general 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 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 data of the OH_UdsFileUri type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap)-Adds data of the OH_UdsPixelMap type to an OH_UdmfRecord instance.
int OH_UdmfRecord_AddArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer)-Adds data 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 OH_UdsFileUri data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap)-Obtains OH_UdsPixelMap data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer)-Obtains OH_UdsArrayBuffer data from an OH_UdmfRecord instance.
int OH_UdmfRecord_GetContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm)-Obtains OH_UdsContentForm data 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 the 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.
OH_UdmfOptions* OH_UdmfOptions_Create()-Creates an OH_UdmfOptions instance. If this pointer is no longer required, use OH_UdmfOptions_Destroy to destroy it. Otherwise, memory leaks may occur.
void OH_UdmfOptions_Destroy(OH_UdmfOptions* pThis)-Destroys an OH_UdmfOptions instance.
const char* OH_UdmfOptions_GetKey(OH_UdmfOptions* pThis)-Obtains the key (unique identifier) from an OH_UdmfOptions instance.
int OH_UdmfOptions_SetKey(OH_UdmfOptions* pThis, const char* key)-Sets the key (unique identifier) in an OH_UdmfOptions instance.
Udmf_Intention OH_UdmfOptions_GetIntention(OH_UdmfOptions* pThis)-Obtains the data channel information from an OH_UdmfOptions instance.
int OH_UdmfOptions_SetIntention(OH_UdmfOptions* pThis, Udmf_Intention intention)-Sets the data channel content parameter in an OH_UdmfOptions instance.
int OH_UdmfOptions_Reset(OH_UdmfOptions* pThis)-Resets an OH_UdmfOptions instance to empty.
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_GetUnifiedDataByOptions(OH_UdmfOptions* options, OH_UdmfData** dataArray, unsigned int* dataSize)-Obtains an OH_UdmfData instance from the UDMF database by data channel type.
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_Udmf_SetUnifiedDataByOptions(OH_UdmfOptions* options, OH_UdmfData *unifiedData, char *key, unsigned int keyLen)-Sets an OH_UdmfData instance in the UDMF database.
int OH_Udmf_UpdateUnifiedData(OH_UdmfOptions* options, OH_UdmfData* unifiedData)-Updates an OH_UdmfData instance in the UDMF database.
int OH_Udmf_DeleteUnifiedData(OH_UdmfOptions* options, OH_UdmfData** dataArray, unsigned int* dataSize)-Deletes an OH_UdmfData instance from the UDMF database.
void OH_Udmf_DestroyDataArray(OH_UdmfData** dataArray, unsigned int dataSize)-Destroys the memory of the data array.
int OH_UdmfProgressInfo_GetProgress(OH_Udmf_ProgressInfo* progressInfo)-Obtains the progress (in percentage) from an OH_Udmf_ProgressInfo instance.
int OH_UdmfProgressInfo_GetStatus(OH_Udmf_ProgressInfo* progressInfo)-Obtains the status information from an OH_Udmf_ProgressInfo instance.
OH_UdmfGetDataParams* OH_UdmfGetDataParams_Create()-Creates an OH_UdmfGetDataParams instance and a pointer to it.
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 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 progress obtained in an OH_UdmfGetDataParams instance.
Udmf_Visibility OH_UdmfOptions_GetVisibility(OH_UdmfOptions* pThis)-Obtains the data visibility level from an OH_UdmfOptions instance.
int OH_UdmfOptions_SetVisibility(OH_UdmfOptions* pThis, Udmf_Visibility visibility)-Sets the data visibility level in an OH_UdmfOptions instance.
typedef OH_UdmfData* (*OH_Udmf_DataLoadHandler)(OH_UdmfDataLoadInfo* acceptableInfo)OH_Udmf_DataLoadHandlerDefines the callback used to load data.
OH_UdmfDataLoadParams* OH_UdmfDataLoadParams_Create()-Creates an OH_UdmfDataLoadParams instance and a pointer to it.
void OH_UdmfDataLoadParams_Destroy(OH_UdmfDataLoadParams* pThis)-Destroys an OH_UdmfDataLoadParams instance.
void OH_UdmfDataLoadParams_SetLoadHandler(OH_UdmfDataLoadParams* params, const OH_Udmf_DataLoadHandler dataLoadHandler)-Sets the processing function for data loading in an OH_UdmfDataLoadParams instance.
void OH_UdmfDataLoadParams_SetDataLoadInfo(OH_UdmfDataLoadParams* params, OH_UdmfDataLoadInfo* dataLoadInfo)-Sets data loading information in an OH_UdmfDataLoadParams instance.
OH_UdmfDataLoadInfo* OH_UdmfDataLoadInfo_Create()-Creates an OH_UdmfDataLoadInfo instance.
void OH_UdmfDataLoadInfo_Destroy(OH_UdmfDataLoadInfo* dataLoadInfo)-Destroys an OH_UdmfDataLoadInfo instance.
char** OH_UdmfDataLoadInfo_GetTypes(OH_UdmfDataLoadInfo* dataLoadInfo, unsigned int* count)-Obtains the data types from an OH_UdmfDataLoadInfo instance.
void OH_UdmfDataLoadInfo_SetType(OH_UdmfDataLoadInfo* dataLoadInfo, const char* type)-Sets the data type in an OH_UdmfDataLoadInfo instance.
int OH_UdmfDataLoadInfo_GetRecordCount(OH_UdmfDataLoadInfo* dataLoadInfo)-Obtains the number of records in an OH_UdmfDataLoadInfo instance.
void OH_UdmfDataLoadInfo_SetRecordCount(OH_UdmfDataLoadInfo* dataLoadInfo, unsigned int recordCount)-Sets the number of records in an OH_UdmfDataLoadInfo instance.
OH_UdmfData* OH_UDMF_GetDataElementAt(OH_UdmfData** dataArray, unsigned int index)-Obtains the unified data object with the specified index from an OH_UdmfData array.

Enum Description

Udmf_Intention

enum Udmf_Intention

Description

Enumerates the UDMF data channel types.

Since: 12

NameDescription
UDMF_INTENTION_DRAGChannel for dragging data.
UDMF_INTENTION_PASTEBOARDChannel for pasteboard data.
UDMF_INTENTION_DATA_HUBPublic data channel.
Since: 20
UDMF_INTENTION_SYSTEM_SHAREChannel for sharing data by the system.
Since: 20
UDMF_INTENTION_PICKERChannel for picker data.
Since: 20
UDMF_INTENTION_MENUChannel for menu data.
Since: 20

Udmf_ShareOption

enum Udmf_ShareOption

Description

Enumerates the options for using the unified data in a device.

Since: 12

NameDescription
SHARE_OPTIONS_INVALIDInvalid use.
SHARE_OPTIONS_IN_APPUnifiedData can be used only in the same application of a device.
SHARE_OPTIONS_CROSS_APPUnifiedData can be used across applications of a device.

Udmf_FileConflictOptions

enum Udmf_FileConflictOptions

Description

Enumerates the options used to resolve file copy conflicts.

Since: 15

NameDescription
UDMF_OVERWRITE = 0Overwrites the file with the same name in the destination directory. This is the default value.
UDMF_SKIP = 1Skips the file if there is a file with the same name in the destination directory.

Udmf_ProgressIndicator

enum Udmf_ProgressIndicator

Description

Enumerates the progress indicator options. You can use the default progress indicator as required.

Since: 15

NameDescription
UDMF_NONE = 0The default progress indicator is not used.
UDMF_DEFAULT = 1The default progress indicator is used. If data is obtained within 500 ms, the default progress bar is not started.

Udmf_Visibility

enum Udmf_Visibility

Description

Enumerates data visibility level.

Since: 20

NameDescription
UDMF_ALLVisible to all applications.
UDMF_OWN_PROCESSVisible only to the data provider.

Function Description

OH_UdmfGetDataParams_SetAcceptableInfo()

void OH_UdmfGetDataParams_SetAcceptableInfo(OH_UdmfGetDataParams* params, OH_UdmfDataLoadInfo* acceptableInfo)

Description

Sets the acceptable data description in an OH_UdmfGetDataParams instance.

Since: 20

Parameters

NameDescription
OH_UdmfGetDataParams* paramsPointer to the OH_UdmfGetDataParams instance.
OH_UdmfDataLoadInfo* acceptableInfoPointer to the OH_UdmfDataLoadInfo instance.

OH_UdmfDataLoadParams_Create()

OH_UdmfDataLoadParams* OH_UdmfDataLoadParams_Create()

Description

Creates an OH_UdmfDataLoadParams instance and a pointer to it.

Since: 20

Returns

TypeDescription
OH_UdmfDataLoadParams*Returns a pointer to the OH_UdmfDataLoadParams instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfDataLoadParams_Destroy()

void OH_UdmfDataLoadParams_Destroy(OH_UdmfDataLoadParams* pThis)

Description

Destroys an OH_UdmfDataLoadParams instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadParams* pThisPointer to the OH_UdmfDataLoadParams instance.

OH_UdmfDataLoadParams_SetLoadHandler()

void OH_UdmfDataLoadParams_SetLoadHandler(OH_UdmfDataLoadParams* params, const OH_Udmf_DataLoadHandler dataLoadHandler)

Description

Sets the processing function for data loading in an OH_UdmfDataLoadParams instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadParams* paramsPointer to the OH_UdmfDataLoadParams instance.
const OH_Udmf_DataLoadHandler dataLoadHandlerUser-defined processing function for data loading.

OH_UdmfDataLoadParams_SetDataLoadInfo()

void OH_UdmfDataLoadParams_SetDataLoadInfo(OH_UdmfDataLoadParams* params, OH_UdmfDataLoadInfo* dataLoadInfo)

Description

Sets data loading information in an OH_UdmfDataLoadParams instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadParams* paramsPointer to the OH_UdmfDataLoadParams instance.
OH_UdmfDataLoadInfo* dataLoadInfoPointer to the OH_UdmfDataLoadInfo instance.

OH_UdmfDataLoadInfo_Create()

OH_UdmfDataLoadInfo* OH_UdmfDataLoadInfo_Create()

Description

Creates an OH_UdmfDataLoadInfo instance.

Since: 20

Returns

TypeDescription
OH_UdmfDataLoadInfo*Returns a pointer to the OH_UdmfDataLoadInfo instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfDataLoadInfo_Destroy()

void OH_UdmfDataLoadInfo_Destroy(OH_UdmfDataLoadInfo* dataLoadInfo)

Description

Destroys an OH_UdmfDataLoadInfo instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadInfo* dataLoadInfoPointer to the OH_UdmfDataLoadInfo instance.

OH_UdmfDataLoadInfo_GetTypes()

char** OH_UdmfDataLoadInfo_GetTypes(OH_UdmfDataLoadInfo* dataLoadInfo, unsigned int* count)

Description

Obtains the data types from an OH_UdmfDataLoadInfo instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadInfo* dataLoadInfoPointer to the OH_UdmfDataLoadInfo instance.
unsigned int* countNumber of data types returned.

Returns

TypeDescription
char**String array of the returned data types.

OH_UdmfDataLoadInfo_SetType()

void OH_UdmfDataLoadInfo_SetType(OH_UdmfDataLoadInfo* dataLoadInfo, const char* type)

Description

Sets the data type in an OH_UdmfDataLoadInfo instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadInfo* dataLoadInfoPointer to the OH_UdmfDataLoadInfo instance.
const char* typeA sting indicating the data type.

OH_UdmfDataLoadInfo_GetRecordCount()

int OH_UdmfDataLoadInfo_GetRecordCount(OH_UdmfDataLoadInfo* dataLoadInfo)

Description

Obtains the number of records in an OH_UdmfDataLoadInfo instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadInfo* dataLoadInfoPointer to the OH_UdmfDataLoadInfo instance.

Returns

TypeDescription
intNumber of records.

OH_UdmfDataLoadInfo_SetRecordCount()

void OH_UdmfDataLoadInfo_SetRecordCount(OH_UdmfDataLoadInfo* dataLoadInfo, unsigned int recordCount)

Description

Sets the number of records in an OH_UdmfDataLoadInfo instance.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadInfo* dataLoadInfoPointer to the OH_UdmfDataLoadInfo instance.
unsigned int recordCountNumber of records.

OH_Udmf_DataLoadHandler()

typedef OH_UdmfData* (*OH_Udmf_DataLoadHandler)(OH_UdmfDataLoadInfo* acceptableInfo)

Description

Defines the callback used to load data.

Since: 20

Parameters

NameDescription
OH_UdmfDataLoadInfo* acceptableInfoData type and data size that can be received.

Returns

TypeDescription
OH_UdmfData* (*OH_Udmf_DataLoadHandler)Data to be loaded.

OH_UdmfOptions_GetVisibility()

Udmf_Visibility OH_UdmfOptions_GetVisibility(OH_UdmfOptions* pThis)

Description

Obtains the data visibility level from an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.

Returns

TypeDescription
Udmf_VisibilityValue of the Udmf_Visibility instance obtained.

OH_UdmfOptions_SetVisibility()

int OH_UdmfOptions_SetVisibility(OH_UdmfOptions* pThis, Udmf_Visibility visibility)

Description

Sets the data visibility level in an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.
Udmf_Visibility visibilityData visibility level Udmf_Visibility.

Returns

TypeDescription
intExecution result. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

UDMF_KEY_BUFFER_LEN()

UDMF_KEY_BUFFER_LEN (512)

Description

Defines minimum length of the buffer that holds the key (unique identifier) of a unified data object.

Since: 12

OH_Udmf_DataProgressListener()

typedef void (*OH_Udmf_DataProgressListener)(OH_Udmf_ProgressInfo* progressInfo, OH_UdmfData* data)

Description

Defines the callback used to return the data retrieval progress information and data obtained.
A null pointer is returned if the progress is less than 100%. The data obtained is returned only when the progress reaches 100%.

Since: 15

Parameters

NameDescription
OH_Udmf_ProgressInfo* progressInfoProgress information obtained.
OH_UdmfData* dataData obtained.

OH_UdmfData_Create()

OH_UdmfData* OH_UdmfData_Create()

Description

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.

Since: 12

Returns

TypeDescription
OH_UdmfData*Returns a pointer to the OH_UdmfData instance created if the operation is successful; returns nullptr otherwise.

See

OH_UdmfData

OH_UdmfData_Destroy()

void OH_UdmfData_Destroy(OH_UdmfData* pThis)

Description

Destroys an OH_UdmfData instance.

Since: 12

Parameters

NameDescription
OH_UdmfData* pThisPointer to the OH_UdmfData instance.

See

OH_UdmfData

OH_UdmfData_AddRecord()

int OH_UdmfData_AddRecord(OH_UdmfData* pThis, OH_UdmfRecord* record)

Description

Adds an OH_UdmfRecord to an OH_UdmfData instance.

Since: 12

Parameters

NameDescription
OH_UdmfData* pThisPointer to the OH_UdmfData instance.
OH_UdmfRecord* recordPointer to the OH_UdmfRecord instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfData_HasType()

bool OH_UdmfData_HasType(OH_UdmfData* pThis, const char* type)

Description

Checks whether the specified type exists in an OH_UdmfData instance.

Since: 12

Parameters

NameDescription
OH_UdmfData* pThisPointer to the OH_UdmfData instance.
const char* typePointer to the type to check.

Returns

TypeDescription
boolCheck result. The value true means the OH_UdmfData instance contains the specified type; the value false means the opposite.

OH_UdmfData_GetTypes()

char** OH_UdmfData_GetTypes(OH_UdmfData* pThis, unsigned int* count)

Description

Obtains all data types in an OH_UdmfData instance.

Since: 12

Parameters

NameDescription
OH_UdmfData* pThisPointer to the OH_UdmfData instance.
unsigned int* countPointer to the number of data types obtained.

Returns

TypeDescription
char**Returns the data types obtained if the operation is successful; returns nullptr otherwise.

OH_UdmfData_GetRecords()

OH_UdmfRecord** OH_UdmfData_GetRecords(OH_UdmfData* pThis, unsigned int* count)

Description

Obtains all records contained in an OH_UdmfData instance.

Since: 12

Parameters

NameDescription
OH_UdmfData* pThisPointer to the OH_UdmfData instance.
unsigned int* countPointer to the number of records obtained.

Returns

TypeDescription
OH_UdmfRecord**Returns a pointer to the OH_UdmfRecord instance created if the operation is successful; returns nullptr otherwise.

UdmfData_Finalize()

typedef void (*UdmfData_Finalize)(void* context)

Description

Defines a callback function used to release the context. This callback is invoked when the OH_UdmfRecordProvider instance is destroyed.

Since: 13

Parameters

NameDescription
void* contextPointer to the context to release.

OH_UdmfRecordProvider_Create()

OH_UdmfRecordProvider* OH_UdmfRecordProvider_Create()

Description

Creates an OH_UdmfRecordProvider instance and a pointer to it. If this pointer is no longer required, use OH_UdmfRecordProvider_Destroy to destroy it. Otherwise, memory leaks may occur.

Since: 13

Returns

TypeDescription
OH_UdmfRecordProvider*Returns a pointer to the OH_UdmfRecordProvider instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfRecordProvider_Destroy()

int OH_UdmfRecordProvider_Destroy(OH_UdmfRecordProvider* provider)

Description

Destroys an OH_UdmfRecordProvider instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecordProvider* providerPointer to the OH_UdmfRecordProvider instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecordProvider_GetData()

typedef void* (*OH_UdmfRecordProvider_GetData)(void* context, const char* type)

Description

Defines a callback function used to obtain data by type. This callback will be invoked to return the data obtained from OH_UdmfRecord.

Since: 13

Parameters

NameDescription
void* contextPointer to the context set by OH_UdmfRecordProvider_SetData.
const char* typePointer to the type of the data to obtain. For details, see udmf_meta.h.

Returns

TypeDescription
void*Uniform data obtained.

OH_UdmfRecordProvider_SetData()

int OH_UdmfRecordProvider_SetData(OH_UdmfRecordProvider* provider, void* context, const OH_UdmfRecordProvider_GetData callback, const UdmfData_Finalize finalize)

Description

Sets a callback for an OH_UdmfRecordProvider instance to provide data.

Since: 13

Parameters

NameDescription
OH_UdmfRecordProvider* providerPointer to the OH_UdmfRecordProvider instance.
void* contextPointer to the context, which is passed as the first parameter to OH_UdmfRecordProvider_GetData.
const OH_UdmfRecordProvider_GetData callbackCallback used to obtain data. For details, see OH_UdmfRecordProvider_GetData.
const UdmfData_Finalize finalizeOptional callback used to release the context data when the OH_UdmfRecordProvider instance is destroyed. For details, see UdmfData_Finalize.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_Create()

OH_UdmfRecord* OH_UdmfRecord_Create()

Description

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.

Since: 12

Returns

TypeDescription
OH_UdmfRecord*Returns a pointer to the OH_UdmfRecord instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfRecord_Destroy()

void OH_UdmfRecord_Destroy(OH_UdmfRecord* pThis)

Description

Destroys an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.

OH_UdmfRecord_AddGeneralEntry()

int OH_UdmfRecord_AddGeneralEntry(OH_UdmfRecord* pThis, const char* typeId, unsigned char* entry, unsigned int count)

Description

Adds customized general data to an OH_UdmfRecord instance. This API cannot be used to add data of UDS types (such as PlainText, Link, and Pixelmap).

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
const char* typeIdPointer to the data type identifier, which is used to distinguish custom data types from system-defined types. It is recommended that the value start with 'ApplicationDefined'.
unsigned char* entryPointer to the customized data to add.
unsigned int countSize of customized data to add. The data size cannot exceed 4 KB.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddPlainText()

int OH_UdmfRecord_AddPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText)

Description

Adds data of the OH_UdsPlainText type to an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsPlainText* plainTextPointer to the OH_UdsPlainText instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddHyperlink()

int OH_UdmfRecord_AddHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink)

Description

Adds data of the OH_UdsHyperlink type to an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsHyperlink* hyperlinkPointer to the OH_UdsHyperlink instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddHtml()

int OH_UdmfRecord_AddHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html)

Description

Adds data of the OH_UdsHtml type to an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsHtml* htmlPointer to the OH_UdsHtml instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddAppItem()

int OH_UdmfRecord_AddAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem)

Description

Adds data of the OH_UdsAppItem type to an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsAppItem* appItemPointer to the OH_UdsAppItem instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddFileUri()

int OH_UdmfRecord_AddFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri)

Description

Adds data of the OH_UdsFileUri type to an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsFileUri* fileUriPointer to the OH_UdsFileUri instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddPixelMap()

int OH_UdmfRecord_AddPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap)

Description

Adds data of the OH_UdsPixelMap type to an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsPixelMap* pixelMapPointer to the OH_UdsPixelMap instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddArrayBuffer()

int OH_UdmfRecord_AddArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer)

Description

Adds data of the OH_UdsArrayBuffer type to an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* recordPointer to the OH_UdmfRecord instance.
const char* typePointer to the ArrayBuffer type ID, which must be unique.
OH_UdsArrayBuffer* bufferPointer to the OH_UdsArrayBuffer instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_AddContentForm()

int OH_UdmfRecord_AddContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm)

Description

Adds data of the OH_UdsContentForm type to an OH_UdmfRecord instance.

Since: 14

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsContentForm* contentFormPointer to the OH_UdsContentForm instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_GetTypes()

char** OH_UdmfRecord_GetTypes(OH_UdmfRecord* pThis, unsigned int* count)

Description

Obtains all data types in an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
unsigned int* countPointer to the number of data types obtained.

Returns

TypeDescription
char**Returns a list of data types obtained if the operation is successful; returns nullptr otherwise.

OH_UdmfRecord_GetGeneralEntry()

int OH_UdmfRecord_GetGeneralEntry(OH_UdmfRecord* pThis, const char* typeId, unsigned char** entry, unsigned int* count)

Description

Obtains the data of the specified type in an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
const char* typeIdPointer to the data type ID.
unsigned char** entryDouble pointer to the data obtained.
unsigned int* countPointer to the length of the data obtained.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs.

OH_UdmfRecord_GetPlainText()

int OH_UdmfRecord_GetPlainText(OH_UdmfRecord* pThis, OH_UdsPlainText* plainText)

Description

Obtains OH_UdsPlainText data from an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsPlainText* plainTextPointer to the OH_UdsPlainText instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs.

OH_UdmfRecord_GetHyperlink()

int OH_UdmfRecord_GetHyperlink(OH_UdmfRecord* pThis, OH_UdsHyperlink* hyperlink)

Description

Obtains OH_UdsHyperlink data from an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsHyperlink* hyperlinkPointer to the OH_UdsHyperlink instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs.

OH_UdmfRecord_GetHtml()

int OH_UdmfRecord_GetHtml(OH_UdmfRecord* pThis, OH_UdsHtml* html)

Description

Obtains OH_UdsHtml data from an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsHtml* htmlPointer to the OH_UdsHtml instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs.

OH_UdmfRecord_GetAppItem()

int OH_UdmfRecord_GetAppItem(OH_UdmfRecord* pThis, OH_UdsAppItem* appItem)

Description

Obtains OH_UdsAppItem data from an OH_UdmfRecord instance.

Since: 12

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsAppItem* appItemPointer to the OH_UdsAppItem instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs.

OH_UdmfRecord_SetProvider()

int OH_UdmfRecord_SetProvider(OH_UdmfRecord* pThis, const char* const* types, unsigned int count, OH_UdmfRecordProvider* provider)

Description

Sets the OH_UdmfRecordProvider in an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
const char* const* typesPointer to the data types to be provided.
unsigned int countNumber of the data types.
OH_UdmfRecordProvider* providerPointer to the OH_UdmfRecordProvider instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_GetFileUri()

int OH_UdmfRecord_GetFileUri(OH_UdmfRecord* pThis, OH_UdsFileUri* fileUri)

Description

Obtains OH_UdsFileUri data from an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsFileUri* fileUriPointer to the OH_UdsFileUri instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_GetPixelMap()

int OH_UdmfRecord_GetPixelMap(OH_UdmfRecord* pThis, OH_UdsPixelMap* pixelMap)

Description

Obtains OH_UdsPixelMap data from an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsPixelMap* pixelMapPointer to the OH_UdsPixelMap instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_GetArrayBuffer()

int OH_UdmfRecord_GetArrayBuffer(OH_UdmfRecord* record, const char* type, OH_UdsArrayBuffer* buffer)

Description

Obtains OH_UdsArrayBuffer data from an OH_UdmfRecord instance.

Since: 13

Parameters

NameDescription
OH_UdmfRecord* recordPointer to the OH_UdmfRecord instance.
const char* typePointer to the data type ID of the ArrayBuffer data to obtain.
OH_UdsArrayBuffer* bufferPointer to the OH_UdsArrayBuffer instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfRecord_GetContentForm()

int OH_UdmfRecord_GetContentForm(OH_UdmfRecord* pThis, OH_UdsContentForm* contentForm)

Description

Obtains OH_UdsContentForm data from an OH_UdmfRecord instance.

Since: 14

Parameters

NameDescription
OH_UdmfRecord* pThisPointer to the OH_UdmfRecord instance.
OH_UdsContentForm* contentFormPointer to the OH_UdsContentForm instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfData_GetPrimaryPlainText()

int OH_UdmfData_GetPrimaryPlainText(OH_UdmfData* data, OH_UdsPlainText* plainText)

Description

Obtains the first OH_UdsPlainText data from an OH_UdmfData instance.

Since: 13

Parameters

NameDescription
OH_UdmfData* dataPointer to the OH_UdmfData instance.
OH_UdsPlainText* plainTextPointer to the OH_UdsPlainText instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfData_GetPrimaryHtml()

int OH_UdmfData_GetPrimaryHtml(OH_UdmfData* data, OH_UdsHtml* html)

Description

Obtains the first OH_UdsHtml data from an OH_UdmfData instance.

Since: 13

Parameters

NameDescription
OH_UdmfData* dataPointer to the OH_UdmfData instance.
OH_UdsHtml* htmlPointer to the OH_UdsHtml instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfData_GetRecordCount()

int OH_UdmfData_GetRecordCount(OH_UdmfData* data)

Description

Obtains the number of data records contained in an OH_UdmfData instance.

Since: 13

Parameters

NameDescription
OH_UdmfData* dataPointer to the OH_UdmfData instance.

Returns

TypeDescription
intNumber of the data records in an OH_UdmfRecord instance obtained.

OH_UdmfData_GetRecord()

OH_UdmfRecord* OH_UdmfData_GetRecord(OH_UdmfData* data, unsigned int index)

Description

Obtains the specified data record from an OH_UdmfData instance.

Since: 13

Parameters

NameDescription
OH_UdmfData* dataPointer to the OH_UdmfData instance.
unsigned int indexSubscript of the OH_UdmfRecord instance to be obtained in OH_UdmfData.

Returns

TypeDescription
OH_UdmfRecord*Returns a pointer to the OH_UdmfRecord instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfData_IsLocal()

bool OH_UdmfData_IsLocal(OH_UdmfData* data)

Description

Checks whether an OH_UdmfData instance is from the local device.

Since: 13

Parameters

NameDescription
OH_UdmfData* dataPointer to the OH_UdmfData instance.

Returns

TypeDescription
boolCheck result. The value true means the data is from the local device; the value false means the opposite.

OH_UdmfProperty_Create()

OH_UdmfProperty* OH_UdmfProperty_Create(OH_UdmfData* unifiedData)

Description

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.

Since: 12

Parameters

NameDescription
OH_UdmfData* unifiedDataPointer to the OH_UdmfData instance.

Returns

TypeDescription
OH_UdmfProperty*Returns a pointer to the OH_UdmfProperty instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfProperty_Destroy()

void OH_UdmfProperty_Destroy(OH_UdmfProperty* pThis)

Description

Destroys an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.

OH_UdmfProperty_GetTag()

const char* OH_UdmfProperty_GetTag(OH_UdmfProperty* pThis)

Description

Obtains the custom tag value from an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.

Returns

TypeDescription
const char*Returns a pointer to the custom tag value obtained if the operation is successful; returns nullptr otherwise.

OH_UdmfProperty_GetTimestamp()

int64_t OH_UdmfProperty_GetTimestamp(OH_UdmfProperty* pThis)

Description

Obtains the timestamp from an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.

Returns

TypeDescription
int64_tTimestamp obtained.

OH_UdmfProperty_GetShareOption()

Udmf_ShareOption OH_UdmfProperty_GetShareOption(OH_UdmfProperty* pThis)

Description

Obtains the share option from an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.

Returns

TypeDescription
Udmf_ShareOptionShare option in the Udmf_ShareOption instance obtained.

OH_UdmfProperty_GetExtrasIntParam()

int OH_UdmfProperty_GetExtrasIntParam(OH_UdmfProperty* pThis, const char* key, int defaultValue)

Description

Obtains the customized extra integer parameter from an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.
const char* keyPointer to the key of the parameter to set.
int defaultValueDefault value to be returned if the parameter fails to be obtained.

Returns

TypeDescription
intReturns the integer value obtained if the operation is successful; returns defaultValue if the operation fails.

OH_UdmfProperty_GetExtrasStringParam()

const char* OH_UdmfProperty_GetExtrasStringParam(OH_UdmfProperty* pThis, const char* key)

Description

Obtains the customized extra string parameter from an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.
const char* keyPointer to the key of the parameter to set.

Returns

TypeDescription
const char*Returns a pointer to the string value obtained if the operation is successful; returns nullptr otherwise.

OH_UdmfProperty_SetTag()

int OH_UdmfProperty_SetTag(OH_UdmfProperty* pThis, const char* tag)

Description

Sets the tag value for an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.
const char* tagPointer to the tag value to set.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfProperty_SetShareOption()

int OH_UdmfProperty_SetShareOption(OH_UdmfProperty* pThis, Udmf_ShareOption option)

Description

Sets the Udmf_ShareOption for an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfProperty instance.
Udmf_ShareOption optionPointer to the Udmf_ShareOption instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfProperty_SetExtrasIntParam()

int OH_UdmfProperty_SetExtrasIntParam(OH_UdmfProperty* pThis, const char* key, int param)

Description

Sets the extra integer parameter for an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfRecord instance.
const char* keyPointer to the key of the parameter to set.
int paramParameter value to set.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfProperty_SetExtrasStringParam()

int OH_UdmfProperty_SetExtrasStringParam(OH_UdmfProperty* pThis, const char* key, const char* param)

Description

Sets the extra string parameter for an OH_UdmfProperty instance.

Since: 12

Parameters

NameDescription
OH_UdmfProperty* pThisPointer to the OH_UdmfRecord instance.
const char* keyPointer to the key of the parameter to set.
const char* paramParameter value to set.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfOptions_Create()

OH_UdmfOptions* OH_UdmfOptions_Create()

Description

Creates an OH_UdmfOptions instance. If this pointer is no longer required, use OH_UdmfOptions_Destroy to destroy it. Otherwise, memory leaks may occur.

Since: 20

Returns

TypeDescription
OH_UdmfOptions*Returns a pointer to the OH_UdmfOptions instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfOptions_Destroy()

void OH_UdmfOptions_Destroy(OH_UdmfOptions* pThis)

Description

Destroys an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.

OH_UdmfOptions_GetKey()

const char* OH_UdmfOptions_GetKey(OH_UdmfOptions* pThis)

Description

Obtains the key (unique identifier) from an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.

Returns

TypeDescription
const char*Returns a pointer to the unique identifier obtained if the operation is successful; returns nullptr otherwise.

OH_UdmfOptions_SetKey()

int OH_UdmfOptions_SetKey(OH_UdmfOptions* pThis, const char* key)

Description

Sets the key (unique identifier) in an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.
const char* keyPointer to the value of the unique identifier of the data.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfOptions_GetIntention()

Udmf_Intention OH_UdmfOptions_GetIntention(OH_UdmfOptions* pThis)

Description

Obtains the data channel information from an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.

Returns

TypeDescription
Udmf_IntentionReturns the value of Udmf_Intent.

OH_UdmfOptions_SetIntention()

int OH_UdmfOptions_SetIntention(OH_UdmfOptions* pThis, Udmf_Intention intention)

Description

Sets the data channel content parameter in an OH_UdmfOptions instance.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.
Udmf_Intention intentionData channel type.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_UdmfOptions_Reset()

int OH_UdmfOptions_Reset(OH_UdmfOptions* pThis)

Description

Resets an OH_UdmfOptions instance to empty.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* pThisPointer to the OH_UdmfOptions instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.

OH_Udmf_GetUnifiedData()

int OH_Udmf_GetUnifiedData(const char* key, Udmf_Intention intention, OH_UdmfData* unifiedData)

Description

Obtains an OH_UdmfData instance from the UDMF database.

Since: 12

Parameters

NameDescription
const char* keyPointer to the unique identifier of the data in the database.
Udmf_Intention intentionData channel type Udmf_Intent.
OH_UdmfData* unifiedDataPointer to the OH_UdmfData instance obtained.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs. The possible cause may be the service error or insufficient memory.

OH_Udmf_GetUnifiedDataByOptions()

int OH_Udmf_GetUnifiedDataByOptions(OH_UdmfOptions* options, OH_UdmfData** dataArray, unsigned int* dataSize)

Description

Obtains an OH_UdmfData instance from the UDMF database by data channel type.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* optionsPointer to the OH_UdmfOptions instance.
OH_UdmfData** dataArrayDouble pointer to the OH_UdmfData instance.
You should use the OH_UDMF_GetDataElementAt function to access each element by subscript.
This double pointer should be released by using the OH_Udmf_DestroyDataArray function.
unsigned int* dataSizePointer to the data size obtained.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs. The possible cause may be the service error or insufficient memory.

OH_Udmf_SetUnifiedData()

int OH_Udmf_SetUnifiedData(Udmf_Intention intention, OH_UdmfData* unifiedData, char* key, unsigned int keyLen)

Description

Sets an OH_UdmfData instance in the UDMF database.

Since: 12

Parameters

NameDescription
Udmf_Intention intentionData channel type Udmf_Intent.
OH_UdmfData* unifiedDataPointer to the OH_UdmfData instance.
char* keyPointer to the key that uniquely identifies the data in the database.
unsigned int keyLenLength of the key. The memory size must be greater than or equal to 512 bytes.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs. The possible cause may be the service error or insufficient memory.

OH_Udmf_SetUnifiedDataByOptions()

int OH_Udmf_SetUnifiedDataByOptions(OH_UdmfOptions* options, OH_UdmfData *unifiedData, char *key, unsigned int keyLen)

Description

Sets an OH_UdmfData instance in the UDMF database.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* optionsPointer to the OH_UdmfOptions instance.
OH_UdmfData *unifiedDataPointer to the OH_UdmfData instance.
char *keyPointer to the key that uniquely identifies the data in the database. The memory size must be greater than UDMF_KEY_BUFFER_LEN.
unsigned int keyLenLength of the key.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs. The possible cause may be the service error or insufficient memory.

OH_Udmf_UpdateUnifiedData()

int OH_Udmf_UpdateUnifiedData(OH_UdmfOptions* options, OH_UdmfData* unifiedData)

Description

Updates an OH_UdmfData instance in the UDMF database.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* optionsPointer to the OH_UdmfOptions instance.
OH_UdmfData* unifiedDataPointer to the OH_UdmfData instance.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs. The possible cause may be the service error or insufficient memory.

OH_Udmf_DeleteUnifiedData()

int OH_Udmf_DeleteUnifiedData(OH_UdmfOptions* options, OH_UdmfData** dataArray, unsigned int* dataSize)

Description

Deletes an OH_UdmfData instance from the UDMF database.

Since: 20

Parameters

NameDescription
OH_UdmfOptions* optionsPointer to the OH_UdmfOptions instance.
OH_UdmfData** dataArrayDouble pointer to the OH_UdmfData instance. You should use the OH_UDMF_GetDataElementAt function to access each element by subscript. This double pointer should be released by using the OH_Udmf_DestroyDataArray function.
unsigned int* dataSizePointer to the data size obtained.

Returns

TypeDescription
intError codes. For details, see Udmf_ErrCode.
Returns UDMF_E_OK if the operation is successful.
Returns UDMF_E_INVALID_PARAM if an invalid parameter is passed in.
Returns UDMF_ERR if an internal data error occurs. The possible cause may be the service error or insufficient memory.

OH_Udmf_DestroyDataArray()

void OH_Udmf_DestroyDataArray(OH_UdmfData** dataArray, unsigned int dataSize)

Description

Destroys the memory of the data array.

Since: 20

Parameters

NameDescription
OH_UdmfData** dataArrayDouble pointer to the OH_UdmfData instance.
unsigned int dataSizeData size.

See

OH_UdmfData

OH_UdmfProgressInfo_GetProgress()

int OH_UdmfProgressInfo_GetProgress(OH_Udmf_ProgressInfo* progressInfo)

Description

Obtains the progress (in percentage) from an OH_Udmf_ProgressInfo instance.

Since: 15

Parameters

NameDescription
OH_Udmf_ProgressInfo* progressInfoPointer to the OH_Udmf_ProgressInfo instance.

Returns

TypeDescription
intProgress obtained, in percentage.

OH_UdmfProgressInfo_GetStatus()

int OH_UdmfProgressInfo_GetStatus(OH_Udmf_ProgressInfo* progressInfo)

Description

Obtains the status information from an OH_Udmf_ProgressInfo instance.

Since: 15

Parameters

NameDescription
OH_Udmf_ProgressInfo* progressInfoPointer to the OH_Udmf_ProgressInfo instance.

Returns

TypeDescription
intStatus information obtained.

OH_UdmfGetDataParams_Create()

OH_UdmfGetDataParams* OH_UdmfGetDataParams_Create()

Description

Creates an OH_UdmfGetDataParams instance and a pointer to it.
If this pointer is no longer required, use OH_UdmfGetDataParams_Destroy to destroy it. Otherwise, memory leaks may occur.

Since: 15

Returns

TypeDescription
OH_UdmfGetDataParams*Returns a pointer to the OH_UdmfGetDataParams instance created if the operation is successful; returns nullptr otherwise.

OH_UdmfGetDataParams_Destroy()

void OH_UdmfGetDataParams_Destroy(OH_UdmfGetDataParams* pThis)

Description

Destroys an OH_UdmfGetDataParams instance.

Since: 15

Parameters

NameDescription
OH_UdmfGetDataParams* pThisPointer to the OH_UdmfGetDataParams instance.

OH_UdmfGetDataParams_SetDestUri()

void OH_UdmfGetDataParams_SetDestUri(OH_UdmfGetDataParams* params, const char* destUri)

Description

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 handle the file copy.

Since: 15

Parameters

NameDescription
OH_UdmfGetDataParams* paramsPointer to the OH_UdmfGetDataParams instance.
const char* destUriDestination directory to set.

OH_UdmfGetDataParams_SetFileConflictOptions()

void OH_UdmfGetDataParams_SetFileConflictOptions(OH_UdmfGetDataParams* params, const Udmf_FileConflictOptions options)

Description

Sets the policy for resolving file conflicts in an OH_UdmfGetDataParams instance.

Since: 15

Parameters

NameDescription
OH_UdmfGetDataParams* paramsPointer to the OH_UdmfGetDataParams instance.
const Udmf_FileConflictOptions optionsPolicy to set.

OH_UdmfGetDataParams_SetProgressIndicator()

void OH_UdmfGetDataParams_SetProgressIndicator(OH_UdmfGetDataParams* params, const Udmf_ProgressIndicator progressIndicator)

Description

Sets the progress indicator in an OH_UdmfGetDataParams instance.

Since: 15

Parameters

NameDescription
OH_UdmfGetDataParams* paramsPointer to the OH_UdmfGetDataParams instance.
const Udmf_ProgressIndicator progressIndicatorWhether to use the default progress indicator.

OH_UdmfGetDataParams_SetDataProgressListener()

void OH_UdmfGetDataParams_SetDataProgressListener(OH_UdmfGetDataParams* params, const OH_Udmf_DataProgressListener dataProgressListener)

Description

Sets the callback used to return the progress obtained in an OH_UdmfGetDataParams instance.

Since: 15

Parameters

NameDescription
OH_UdmfGetDataParams* paramsPointer to the OH_UdmfGetDataParams instance.
const OH_Udmf_DataProgressListener dataProgressListenerCallback to set.

OH_UDMF_GetDataElementAt()

OH_UdmfData* OH_UDMF_GetDataElementAt(OH_UdmfData** dataArray, unsigned int index)

Description

Obtains the unified data object with the specified index from an OH_UdmfData array.

Since: 22

Parameters

NameDescription
OH_UdmfData** dataArrayDouble pointer to the OH_UdmfData array.
Only the arrays obtained from the OH_Udmf_GetUnifiedDataByOptions and OH_Udmf_DeleteUnifiedData APIs are accepted.
unsigned int indexIndex of the unified data object to be obtained. Ensure that the value does not exceed the array range. Otherwise, out-of-bounds array occurs.

Returns

TypeDescription
OH_UdmfData*Returns a pointer to the OH_UdmfData instance if the execution is successful; returns null if the input array is empty.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 js-apis-distributedKVStore-sys

openharmony 鸿蒙 capi-oh-preferences-h

openharmony 鸿蒙 capi-udmf-oh-udshyperlink

openharmony 鸿蒙 js-apis-data-dataSharePredicates

openharmony 鸿蒙 capi-udmf-oh-udsappitem

openharmony 鸿蒙 capi-rdb-oh-data-vbuckets

openharmony 鸿蒙 capi-rdb-oh-predicates

openharmony 鸿蒙 capi-rdb-oh-data-value

openharmony 鸿蒙 capi-preferences-oh-preferencespair

openharmony 鸿蒙 errorcode-datashare

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