openharmony 鸿蒙 dataability-lifecycle

2023-02-03 浏览 (769)

DataAbility Lifecycle

You can implement lifecycle callbacks (as described in the table below) in data.js or data.ets.

Table 1 DataAbility lifecycle APIs

APIDescription
onInitialized?(info: AbilityInfo): voidCalled during ability initialization to initialize the relational database (RDB).
update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): voidUpdates data in the database.
query?(uri: string, columns: Array<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<ResultSet>): voidQueries data in the database.
delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback<number>): voidDeletes one or more data records from the database.
normalizeUri?(uri: string, callback: AsyncCallback<string>): voidNormalizes the URI. A normalized URI applies to cross-device use, persistence, backup, and restore. When the context changes, it ensures that the same data item can be referenced.
batchInsert?(uri: string, valueBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback<number>): voidInserts multiple data records into the database.
denormalizeUri?(uri: string, callback: AsyncCallback<string>): voidConverts a normalized URI generated by normalizeUri into a denormalized URI.
insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback<number>): voidInserts a data record into the database.
openFile?(uri: string, mode: string, callback: AsyncCallback<number>): voidOpens a file.
getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array<string>>): voidObtains the MIME type of a file.
getType?(uri: string, callback: AsyncCallback<string>): voidObtains the MIME type matching the data specified by the URI.
executeBatch?(ops: Array<DataAbilityOperation>, callback: AsyncCallback<Array<DataAbilityResult>>): voidOperates data in the database in batches.
call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback<PacMap>): voidCalls a custom API.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙Obtaining Reasons for Abnormal Application Exits

harmony 鸿蒙UIAbility Backup and Restore

harmony 鸿蒙Using Explicit Want to Start an Application Component

harmony 鸿蒙Introduction to Ability Kit

harmony 鸿蒙AbilityStage Component Container

harmony 鸿蒙Accessing a DataAbility

harmony 鸿蒙Accessing a DataShareExtensionAbility from the FA Model

harmony 鸿蒙Common action and entities Values (Not Recommended)

harmony 鸿蒙API Switching Overview

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