From abb3fd23ab963ba32bbdf4efa4e5c678a63173cb Mon Sep 17 00:00:00 2001 From: Gloria Date: Thu, 24 Nov 2022 19:42:28 +0800 Subject: [PATCH] Update docs against 11048 Signed-off-by: wusongqing --- en/application-dev/ability/fa-dataability.md | 31 ++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/en/application-dev/ability/fa-dataability.md b/en/application-dev/ability/fa-dataability.md index faad709b28..1319ba6868 100644 --- a/en/application-dev/ability/fa-dataability.md +++ b/en/application-dev/ability/fa-dataability.md @@ -6,25 +6,24 @@ A Data ability helps applications manage access to data stored by themselves and Data ability providers can customize data access-related APIs such as data inserting, deleting, updating, and querying, as well as file opening, and share data with other applications through these open APIs. - ## Available APIs **Table 1** Data ability lifecycle APIs |API|Description| |:------|:------| -|onInitialized?(info: AbilityInfo): void|Called during ability initialization to initialize the relational database (RDB).| -|update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Updates data in the database.| -|query?(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Queries data in the database.| -|delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Deletes one or more data records from the database.| -|normalizeUri?(uri: string, callback: AsyncCallback\): void|Normalizes 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\, callback: AsyncCallback\): void|Inserts multiple data records into the database.| -|denormalizeUri?(uri: string, callback: AsyncCallback\): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| -|insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void|Inserts a data record into the database.| -|openFile?(uri: string, mode: string, callback: AsyncCallback\): void|Opens a file.| -|getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void|Obtains the MIME type of a file.| -|getType?(uri: string, callback: AsyncCallback\): void|Obtains the MIME type matching the data specified by the URI.| -|executeBatch?(ops: Array\, callback: AsyncCallback\>): void|Operates data in the database in batches.| -|call?(method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void|Calls a custom API.| +|onInitialized(info: AbilityInfo): void|Called during ability initialization to initialize the relational database (RDB).| +|update(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Updates data in the database.| +|query(uri: string, columns: Array\, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Queries data in the database.| +|delete(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\): void|Deletes one or more data records from the database.| +|normalizeUri(uri: string, callback: AsyncCallback\): void|Normalizes 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\, callback: AsyncCallback\): void|Inserts multiple data records into the database.| +|denormalizeUri(uri: string, callback: AsyncCallback\): void|Converts a normalized URI generated by **normalizeUri** into a denormalized URI.| +|insert(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\): void|Inserts a data record into the database.| +|openFile(uri: string, mode: string, callback: AsyncCallback\): void|Opens a file.| +|getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void|Obtains the MIME type of a file.| +|getType(uri: string, callback: AsyncCallback\): void|Obtains the MIME type matching the data specified by the URI.| +|executeBatch(ops: Array\, callback: AsyncCallback\>): void|Operates data in the database in batches.| +|call(method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void|Calls a custom API.| ## How to Develop @@ -35,6 +34,7 @@ Data ability providers can customize data access-related APIs such as data inser The following code snippet shows how to create a Data ability: ```javascript + import featureAbility from '@ohos.ability.featureAbility' import dataAbility from '@ohos.data.dataAbility' import dataRdb from '@ohos.data.rdb' @@ -46,7 +46,8 @@ Data ability providers can customize data access-related APIs such as data inser export default { onInitialized(abilityInfo) { console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName) - dataRdb.getRdbStore(STORE_CONFIG, 1, (err, store) => { + let context = featureAbility.getContext() + dataRdb.getRdbStore(context, STORE_CONFIG, 1, (err, store) => { console.info('DataAbility getRdbStore callback') store.executeSql(SQL_CREATE_TABLE, []) rdbStore = store -- GitLab