harmony 鸿蒙Data

2025-06-12 浏览 (1)

Data

Overview

Data (distributed data manager) supports persistence of various structured data on a single device, and data sync and sharing between a device and the cloud. It defines a series of data types for operations, such as data addition, deletion, modification, and query.

System capability: SystemCapability.DistributedDataManager.RelationalStore.Core

Since: 11

Summary

File

NameDescription
data_asset.hDefines data asset structures.
File to include: <database/data/data_asset.h>
Library: libnative_rdb_ndk.z.so

Types

NameDescription
Data_AssetStatusDefines an enum for data asset statuses.
Data_AssetDefines a struct for a data asset.

Enums

NameDescription
Data_AssetStatus {
ASSET_NULL = 0, ASSET_NORMAL, ASSET_INSERT, ASSET_UPDATE,
ASSET_DELETE, ASSET_ABNORMAL, ASSET_DOWNLOADING
}
Enumerates the data asset statuses.

Functions

NameDescription
OH_Data_Asset_SetName (Data_Asset *asset, const char *name)Sets the name of a data asset.
OH_Data_Asset_SetUri (Data_Asset *asset, const char *uri)Sets the absolute path (URI) of a data asset in the system.
OH_Data_Asset_SetPath (Data_Asset *asset, const char *path)Sets the relative path of a data asset in the application sandbox directory.
OH_Data_Asset_SetCreateTime (Data_Asset *asset, int64_t createTime)Sets the creation time for a data asset.
OH_Data_Asset_SetModifyTime (Data_Asset *asset, int64_t modifyTime)Sets the last modification time for a data asset.
OH_Data_Asset_SetSize (Data_Asset *asset, size_t size)Sets the size of a data asset.
OH_Data_Asset_SetStatus (Data_Asset *asset, Data_AssetStatus status)Sets the status of a data asset.
OH_Data_Asset_GetName (Data_Asset *asset, char *name, size_t *length)Obtains the name of a data asset.
OH_Data_Asset_GetUri (Data_Asset *asset, char *uri, size_t *length)Obtains the absolute path of a data asset.
OH_Data_Asset_GetPath (Data_Asset *asset, char *path, size_t *length)Obtains the relative path of a data asset.
OH_Data_Asset_GetCreateTime (Data_Asset *asset, int64_t *createTime)Obtains the creation time of a data asset.
OH_Data_Asset_GetModifyTime (Data_Asset *asset, int64_t *modifyTime)Obtains the last modification time of a data asset.
OH_Data_Asset_GetSize (Data_Asset *asset, size_t *size)Obtains the space occupied by a data asset.
OH_Data_Asset_GetStatus (Data_Asset *asset, Data_AssetStatus *status)Obtains the status of a data asset.
OH_Data_Asset_CreateOne ()Creates a Data_Asset instance.
OH_Data_Asset_DestroyOne (Data_Asset *asset)Destroys a Data_Asset instance.
OH_Data_Asset_CreateMultiple (uint32_t count)Creates multiple Data_Asset instances.
OH_Data_Asset_DestroyMultiple (Data_Asset **assets, uint32_t count)Destroys multiple Data_Asset instances.

Type Description

Data_Asset

typedef struct Data_Asset Data_Asset

Description

Defines a struct for a data asset.

It provides information about a data asset.

Since: 11

Enum Description

Data_AssetStatus

enum Data_AssetStatus

Description

Enumerates the data asset statuses.

ValueDescription
ASSET_NULLThe data asset is null.
ASSET_NORMALThe data asset is in normal status.
ASSET_INSERTThe data asset is to be inserted to the cloud.
ASSET_UPDATEThe data asset is to be updated to the cloud.
ASSET_DELETEThe data asset is to be deleted from the cloud.
ASSET_ABNORMALThe data asset is in abnormal status.
ASSET_DOWNLOADINGThe data asset is being downloaded to a local device.

Function Description

OH_Data_Asset_CreateMultiple()

Data_Asset** OH_Data_Asset_CreateMultiple (uint32_t count)

Description

Creates multiple Data_Asset instances.

Since: 11

Parameters

NameDescription
countNumber of data assets to create.

Returns

Returns the pointer to the Data_Asset instance created if the operation is successful; returns null otherwise.

See

Data_Asset.

OH_Data_Asset_CreateOne()

Data_Asset* OH_Data_Asset_CreateOne ()

Description

Creates a Data_Asset instance.

Since: 11

Returns

Returns the pointer to the Data_Asset instance created if the operation is successful; returns null otherwise.

See

Data_Asset.

OH_Data_Asset_DestroyMultiple()

int OH_Data_Asset_DestroyMultiple (Data_Asset ** assets, uint32_t count )

Description

Destroys multiple Data_Asset instances.

Since: 11

Parameters

NameDescription
assetsPointer to the Data_Asset instances to destroy.
countNumber of the Data_Asset instances to destroy.

Returns

Returns RDB_OK if the operation is successful; returns an error code otherwise. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset, OH_Rdb_ErrCode.

OH_Data_Asset_DestroyOne()

int OH_Data_Asset_DestroyOne (Data_Asset * asset)

Description

Destroys a Data_Asset instance.

Since: 11

Parameters

NameDescription
assetPointer to the Data_Asset instance to destroy.

Returns

Returns RDB_OK if the operation is successful; returns an error code otherwise. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset, OH_Rdb_ErrCode.

OH_Data_Asset_GetCreateTime()

int OH_Data_Asset_GetCreateTime (Data_Asset * asset, int64_t * createTime )

Description

Obtains the creation time of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
createTimePonter to the creation time obtained, in int64_t format.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_GetModifyTime()

int OH_Data_Asset_GetModifyTime (Data_Asset * asset, int64_t * modifyTime )

Description

Obtains the last modification time of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
modifyTimePointer to the last modification time obtained, in int64_t format.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_GetName()

int OH_Data_Asset_GetName (Data_Asset * asset, char * name, size_t * length )

Description

Obtains the name of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
namePointer to the data asset name obtained, in the form of a string.
lengthPointer to the length of the name.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_GetPath()

int OH_Data_Asset_GetPath (Data_Asset * asset, char * path, size_t * length )

Description

Obtains the relative path of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
pathPointer to the relative path of the data asset obtained, in the form of a string.
lengthPointer to the length of the relative path.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_GetSize()

int OH_Data_Asset_GetSize (Data_Asset * asset, size_t * size )

Description

Obtains the space occupied by a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
sizePointer to the data asset size obtained, in the format of size_t.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_GetStatus()

int OH_Data_Asset_GetStatus (Data_Asset * asset, Data_AssetStatus * status )

Description

Obtains the status of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
statusPointer to the Data_AssetStatus obtained.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_GetUri()

int OH_Data_Asset_GetUri (Data_Asset * asset, char * uri, size_t * length )

Description

Obtains the absolute path (URI) of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
uriPointer to the absolute path of the data asset obtained, in the form of a string.
lengthPointer to the length of the URI.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_SetCreateTime()

int OH_Data_Asset_SetCreateTime (Data_Asset * asset, int64_t createTime )

Description

Sets the creation time for a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
createTimeCreation time to set.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_SetModifyTime()

int OH_Data_Asset_SetModifyTime (Data_Asset * asset, int64_t modifyTime )

Description

Sets the last modification time for a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
modifyTimeLast modification time to set.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_SetName()

int OH_Data_Asset_SetName (Data_Asset * asset, const char * name )

Description

Sets the name of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
namePointer to the name to set.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_SetPath()

int OH_Data_Asset_SetPath (Data_Asset * asset, const char * path )

Description

Sets the relative path of a data asset in the application sandbox directory.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
pathPointer to the relative path to set.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_SetSize()

int OH_Data_Asset_SetSize (Data_Asset * asset, size_t size )

Description

Sets the size of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
sizeSize of the data asset to set.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

OH_Data_Asset_SetStatus()

int OH_Data_Asset_SetStatus (Data_Asset * asset, Data_AssetStatus status )

Description

Sets the status of a data asset.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
statusStatus to set. For details, see Data_AssetStatus.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset, Data_AssetStatus

OH_Data_Asset_SetUri()

int OH_Data_Asset_SetUri (Data_Asset * asset, const char * uri )

Description

Sets the absolute path (URI) of a data asset in the system.

Since: 11

Parameters

NameDescription
assetPointer to the target Data_Asset instance.
namePointer to the URI to set.

Returns

Returns an error code. For details about the error codes, see OH_Rdb_ErrCode.

See

Data_Asset

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkData (ArkData Management)

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

harmony 鸿蒙Rdb_ChangeInfo

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