Data

Overview

Data (distributed data manager) supports persistence of various structured data on a single device, and data synchronization 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

Name Description
data_asset.h Defines data asset structures.

Types

Name Description
Data_AssetStatus Defines an enum for data asset statuses.
Data_Asset Defines a struct for a data asset.

Enums

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

Functions

Name Description
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.

Value Description
ASSET_NULL The data asset is null.
ASSET_NORMAL The data asset is in normal status.
ASSET_INSERT The data asset is to be inserted to the cloud.
ASSET_UPDATE The data asset is to be updated to the cloud.
ASSET_DELETE The data asset is to be deleted from the cloud.
ASSET_ABNORMAL The data asset is in abnormal status.
ASSET_DOWNLOADING The 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

Name Description
count Number 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

Name Description
assets Pointer to the Data_Asset instances to destroy.
count Number 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

Name Description
asset Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
createTime Ponter 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

Name Description
asset Pointer to the target Data_Asset instance.
modifyTime Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
name Pointer to the data asset name obtained, in the form of a string.
length Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
path Pointer to the relative path of the data asset obtained, in the form of a string.
length Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
size Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
status Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
uri Pointer to the absolute path of the data asset obtained, in the form of a string.
length Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
createTime Creation 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

Name Description
asset Pointer to the target Data_Asset instance.
modifyTime Last 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

Name Description
asset Pointer to the target Data_Asset instance.
name Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
path Pointer 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

Name Description
asset Pointer to the target Data_Asset instance.
size Size 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

Name Description
asset Pointer to the target Data_Asset instance.
status Status 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

Name Description
asset Pointer to the target Data_Asset instance.
name Pointer to the URI to set.

Returns

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

See

Data_Asset