提交 ba3112c1 编写于 作者: X xuchenghua09

Update js-apis

Signed-off-by: Nxuchenghua09 <xuchenghua09@huawei.com>
上级 0a6d3fe9
# Context模块(JS端SDK接口) # Context模块
#### 支持设备 ## 支持设备
| API | 手机 | 平板 | 智慧屏 | 智能穿戴 | 轻量级智能穿戴 | 智慧视觉设备 | | API | 手机 | 平板 | 智慧屏 | 智能穿戴 | 轻量级智能穿戴 | 智慧视觉设备 |
| ------------------------------------------------------------ | ---- | ---- | ------ | -------- | -------------- | ------------ | | ------------------------------------------------------------ | ---- | ---- | ------ | -------- | -------------- | ------------ |
...@@ -23,18 +23,22 @@ ...@@ -23,18 +23,22 @@
| Context.getCallingBundle(callback: AsyncCallback\<string>) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | | Context.getCallingBundle(callback: AsyncCallback\<string>) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |
| Context.getCallingBundle() | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | | Context.getCallingBundle() | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |
#### 权限列表 ## 导入模块
**ohos.permission.RUNNING_LOCK permission** ```js
import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle'
```
#### 导入模块 Context对象是在featureAbility中创建实例,并通过featureAbility的getContext()接口返回,因此在使用Context时,必须导入@ohos.ability.featureAbility库。示例如下:
``` ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle' var context = featureAbility.getContext();
context.getOrCreateLocalDir()
``` ```
#### Context.getOrCreateLocalDir(callback: AsyncCallback\<string>) ## Context.getOrCreateLocalDir(callback: AsyncCallback<string>)
- 接口说明 - 接口说明
...@@ -44,24 +48,26 @@ import bundle from '@ohos.bundle' ...@@ -44,24 +48,26 @@ import bundle from '@ohos.bundle'
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ----------------------- | ---- | ---------------- | | -------- | -------- | ---------------------- | ---- | ------------------------ |
| callback | 只读 | AsyncCallback\<string>) | 是 | 被指定的回调方法 | | callback | 只读 | AsyncCallback\<string> | 是 | 返回应用程序的本地根目录 |
- 返回值 - 返回值
根目录 void
- 示例 - 示例
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var context = featureAbility.getContext(); var context = featureAbility.getContext();
context.getOrCreateLocalDir() context.getOrCreateLocalDir((err, data)=>{
console.info("data=" + data);
})
``` ```
#### Context.getOrCreateLocalDir() ## Context.getOrCreateLocalDir()
- 接口说明 - 接口说明
...@@ -69,7 +75,9 @@ context.getOrCreateLocalDir() ...@@ -69,7 +75,9 @@ context.getOrCreateLocalDir()
- 返回值 - 返回值
根目录 | 类型 | 说明 |
| --------------- | -------------------- |
| Promise<string> | 应用程序的本地根目录 |
- 示例 - 示例
...@@ -81,33 +89,31 @@ context.getOrCreateLocalDir().then((void) => { ...@@ -81,33 +89,31 @@ context.getOrCreateLocalDir().then((void) => {
}); });
``` ```
## PermissionOptions类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---- | -------- | ------ | ---- | ------ |
| pid | 只读 | number | 否 | 进程id |
| uid | 只读 | number | 否 | 用户id |
#### Context.verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>) ## Context.verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback<number>)
- 接口说明 - 接口说明
验证系统中运行的特定pid和uid是否允许指定的权限(callback形式) 验证系统中运行的特定pid和uid是否允许指定的权限(callback形式)
- verifyPermission参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---------- | -------- | ---------------------- | ---- | ---------------- | | ---------- | -------- | ----------------------------------------------- | ---- | ----------------------------------- |
| permission | 只读 | string | 是 | 指定权限的名称 | | permission | 只读 | string | 是 | 指定权限的名称 |
| options | 只读 | PermissionOptions | 是 | 进程id | | options | 只读 | [PermissionOptions](#PermissionOptions类型说明) | 是 | 进程id |
| callback | 只读 | AsyncCallback\<number> | 是 | 被指定的回调方法 | | callback | 只读 | AsyncCallback\<number> | 是 | 返回权限验证结果,0有权限,-1无权限 |
- PermissionOptions类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---- | -------- | ------ | ---- | ------ |
| pid | 只读 | number | 否 | 进程id |
| uid | 只读 | number | 否 | 用户id |
- 返回值 - 返回值
如果PID和UID具有权限,则使用{@code 0}进行异步回调;否则使用{@code-1}回调。 void
- 示例 - 示例
...@@ -116,29 +122,29 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -116,29 +122,29 @@ import featureAbility from '@ohos.ability.featureAbility'
import bundle from '@ohos.bundle' import bundle from '@ohos.bundle'
var context = featureAbility.getContext(); var context = featureAbility.getContext();
var datainfo = await bundle.getBundleInfo('com.context.test',1); var datainfo = await bundle.getBundleInfo('com.context.test',1);
context.verifyPermission("com.example.permission",datainfo.uid,) context.verifyPermission("com.example.permission",datainfo.uid)
``` ```
#### Context.verifyPermission(permission: string, callback: AsyncCallback\<number>) ## Context.verifyPermission(permission: string, callback: AsyncCallback<number>)
- 接口说明 - 接口说明
验证系统中运行的特定pid和uid是否允许指定的权限(callback形式) 验证系统中运行的特定pid和uid是否具有指定的权限(callback形式)
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---------- | -------- | ----------------------- | ---- | ---------------- | | ---------- | -------- | ---------------------- | ---- | ----------------------------------- |
| permission | 只读 | string | 是 | 指定权限的名称 | | permission | 只读 | string | 是 | 指定权限的名称 |
| callback | 只读 | AsyncCallback\<number>) | 是 | 被指定的回调方法 | | callback | 只读 | AsyncCallback\<number> | 是 | 返回权限验证结果,0有权限,-1无权限 |
- 返回值 - 返回值
如果PID和UID具有权限,则使用{@code 0}进行异步回调;否则使用{@code-1}回调。 void
- 示例 - 示例
...@@ -150,29 +156,24 @@ context.verifyPermission("com.example.permission") ...@@ -150,29 +156,24 @@ context.verifyPermission("com.example.permission")
#### Context.verifyPermission(permission: string, options?: PermissionOptions) ## Context.verifyPermission(permission: string, options?: PermissionOptions)
- 接口说明 - 接口说明
验证系统中运行的特定pid和uid是否允许指定的权限(Promise形式) 验证系统中运行的特定pid和uid是否具有指定的权限(Promise形式)
- verifyPermission参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---------- | -------- | ----------------- | ---- | -------------- | | ---------- | -------- | ----------------------------------------------- | ---- | -------------- |
| permission | 只读 | string | 是 | 指定权限的名称 | | permission | 只读 | string | 是 | 指定权限的名称 |
| options | 只读 | PermissionOptions | 否 | 进程id | | options | 只读 | [PermissionOptions](#PermissionOptions类型说明) | 否 | 进程id |
- PermissionOptions类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---- | -------- | ------ | ---- | ------ |
| pid | 只读 | number | 否 | 进程id |
| uid | 只读 | number | 否 | 用户id |
- 返回值 - 返回值
如果PID和UID具有权限,则使用{@code 0}进行异步回调;否则使用{@code-1}回调。 | 类型 | 说明 |
| --------------- | ------------------------------------------------------------ |
| Promise<number> | 如果pid和uid具有权限,则使用{@code 0}进行异步回调;否则使用{@code-1}回调。 |
- 示例 - 示例
...@@ -185,9 +186,17 @@ context.getOrCreateLocalDir('com.context.permission',Permission).then((void) => ...@@ -185,9 +186,17 @@ context.getOrCreateLocalDir('com.context.permission',Permission).then((void) =>
}); });
``` ```
## PermissionRequestResult类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | 只读 | number | 是 | 用户传入的请求代码 |
| permissions | 只读 | Array\<string> | 是 | 用户传入的权限 |
| authResults | 只读 | Array\<number> | 是 | 求权限的结果 |
#### Context.requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback\<PermissionRequestResult>) ## Context.requestPermissionsFromUser(permissions: Array<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#PermissionRequestResult类型说明)>)
- 接口说明 - 接口说明
...@@ -197,18 +206,10 @@ context.getOrCreateLocalDir('com.context.permission',Permission).then((void) => ...@@ -197,18 +206,10 @@ context.getOrCreateLocalDir('com.context.permission',Permission).then((void) =>
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------------- | -------- | ---------------------------------------- | ---- | --------------------------------------------- | | -------------- | -------- | ------------------------------------------------------------ | ---- | --------------------------------------------- |
| permissions | 只读 | Array\<string> | 是 | 指示要请求的权限列表。此参数不能为null | | permissions | 只读 | Array\<string> | 是 | 指示要请求的权限列表。此参数不能为null |
| requestCode | 只读 | number | 是 | 指示要传递给PermissionRequestResult的请求代码 | | requestCode | 只读 | number | 是 | 指示要传递给PermissionRequestResult的请求代码 |
| resultCallback | 只读 | AsyncCallback\<PermissionRequestResult>) | 是 | 被指定的回调方法 | | resultCallback | 只读 | AsyncCallback\<[PermissionRequestResult](#PermissionRequestResult类型说明)> | 是 | 返回授权结果信息 |
- PermissionRequestResult类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | 只读 | number | 是 | 用户传入的请求代码 |
| permissions | 只读 | Array\<string> | 是 | 用户传入的权限 |
| authResults | 只读 | Array\<number> | 是 | 求权限的结果 |
- 返回值 - 返回值
void void
...@@ -230,7 +231,7 @@ context.getOrCreateLocalDir( ...@@ -230,7 +231,7 @@ context.getOrCreateLocalDir(
#### Context.getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>) ## Context.getApplicationInfo(callback: AsyncCallback<ApplicationInfo>)
- 接口说明 - 接口说明
...@@ -239,8 +240,8 @@ context.getOrCreateLocalDir( ...@@ -239,8 +240,8 @@ context.getOrCreateLocalDir(
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ------------------------------- | ---- | -------------------- | | -------- | -------- | ------------------------------- | ---- | ---------------------- |
| callback | 只读 | AsyncCallback\<ApplicationInfo> | 是 | 表示被指定的回调方法 | | callback | 只读 | AsyncCallback\<ApplicationInfo> | 是 | 返回当前应用程序的信息 |
- 返回值 - 返回值
...@@ -256,7 +257,7 @@ context.getApplicationInfo() ...@@ -256,7 +257,7 @@ context.getApplicationInfo()
#### Context.getApplicationInfo() ## Context.getApplicationInfo
- 接口说明 - 接口说明
...@@ -264,11 +265,13 @@ context.getApplicationInfo() ...@@ -264,11 +265,13 @@ context.getApplicationInfo()
- 参数描述 - 参数描述
Null
- 返回值 - 返回值
void | 类型 | 说明 |
| ------------------------ | ------------------ |
| Promise<ApplicationInfo> | 当前应用程序的信息 |
- 示例 - 示例
...@@ -282,7 +285,7 @@ context.getApplicationInfo().then((void) => { ...@@ -282,7 +285,7 @@ context.getApplicationInfo().then((void) => {
#### Context.getBundleName(callback: AsyncCallback\<string>) ## Context.getBundleName(callback: AsyncCallback<string>)
- 接口说明 - 接口说明
...@@ -291,8 +294,8 @@ context.getApplicationInfo().then((void) => { ...@@ -291,8 +294,8 @@ context.getApplicationInfo().then((void) => {
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ---------------------- | ---- | -------------------- | | -------- | -------- | ---------------------- | ---- | --------------------------- |
| callback | 只读 | AsyncCallback\<string> | 是 | 表示被指定的回调方法 | | callback | 只读 | AsyncCallback\<string> | 是 | 返回当前ability的捆绑包名称 |
- 返回值 - 返回值
...@@ -308,7 +311,7 @@ context.getBundleName() ...@@ -308,7 +311,7 @@ context.getBundleName()
#### Context.getBundleName() ## Context.getBundleName
- 接口说明 - 接口说明
...@@ -316,11 +319,13 @@ context.getBundleName() ...@@ -316,11 +319,13 @@ context.getBundleName()
- 参数描述 - 参数描述
Null
- 返回值 - 返回值
void | 类型 | 说明 |
| --------------- | ----------------------- |
| Promise<string> | 当前ability的捆绑包名称 |
- 示例 - 示例
...@@ -334,7 +339,7 @@ context.getBundleName().then((void) => { ...@@ -334,7 +339,7 @@ context.getBundleName().then((void) => {
#### Context.getProcessInfo(callback: AsyncCallback\<ProcessInfo>) ## Context.getProcessInfo(callback: AsyncCallback<ProcessInfo>)
- 接口说明 - 接口说明
...@@ -343,8 +348,8 @@ context.getBundleName().then((void) => { ...@@ -343,8 +348,8 @@ context.getBundleName().then((void) => {
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | --------------------------- | ---- | -------------------- | | -------- | -------- | --------------------------- | ---- | ------------------ |
| callback | 只读 | AsyncCallback\<ProcessInfo> | 是 | 表示被指定的回调方法 | | callback | 只读 | AsyncCallback\<ProcessInfo> | 是 | 返回当前进程的信息 |
- 返回值 - 返回值
...@@ -360,19 +365,21 @@ context.getProcessInfo() ...@@ -360,19 +365,21 @@ context.getProcessInfo()
#### Context.getProcessInfo() ## Context.getProcessInfo
- 接口说明 - 接口说明
获取有关当前进程的信息,包括进程ID和名称(Promise形式) 获取有关当前进程的信息,包括进程id和名称(Promise形式)
- 参数描述 - 参数描述
Null
- 返回值 - 返回值
void | 类型 | 说明 |
| -------------------- | -------------- |
| Promise<ProcessInfo> | 当前进程的信息 |
- 示例 - 示例
...@@ -386,17 +393,17 @@ context.getProcessInfo().then((void) => { ...@@ -386,17 +393,17 @@ context.getProcessInfo().then((void) => {
#### Context.getElementName(callback: AsyncCallback\<ElementName>) ## Context.getElementName(callback: AsyncCallback<ElementName>)
- 接口说明 - 接口说明
获取当前能力的ohos.bundle.ElementName对象。此方法仅适用于页面功能(callback形式) 获取当前ability的ohos.bundle.ElementName对象。此方法仅适用于页面功能(callback形式)
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | --------------------------- | ---- | -------------------- | | -------- | -------- | --------------------------- | ---- | -------------------------------------------- |
| callback | 只读 | AsyncCallback\<ElementName> | 是 | 表示被指定的回调方法 | | callback | 只读 | AsyncCallback\<ElementName> | 是 | 返回当前ability的ohos.bundle.ElementName对象 |
- 返回值 - 返回值
...@@ -412,7 +419,7 @@ context.getElementName() ...@@ -412,7 +419,7 @@ context.getElementName()
#### Context.getElementName() ## Context.getElementName
- 接口说明 - 接口说明
...@@ -420,11 +427,13 @@ context.getElementName() ...@@ -420,11 +427,13 @@ context.getElementName()
- 参数描述 - 参数描述
Null
- 返回值 - 返回值
void | 类型 | 说明 |
| -------------------- | ---------------------------------------- |
| Promise<ElementName> | 当前ability的ohos.bundle.ElementName对象 |
- 示例 - 示例
...@@ -436,9 +445,7 @@ context.getElementName().then((void) => { ...@@ -436,9 +445,7 @@ context.getElementName().then((void) => {
}); });
``` ```
#### ## **Context.getProcessName(callback: AsyncCallback<string>)**
#### Context.getProcessName(callback: AsyncCallback\<string>)
- 接口说明 - 接口说明
...@@ -447,8 +454,8 @@ context.getElementName().then((void) => { ...@@ -447,8 +454,8 @@ context.getElementName().then((void) => {
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ---------------------- | ---- | -------------------- | | -------- | -------- | ---------------------- | ---- | ------------------ |
| callback | 只读 | AsyncCallback\<string> | 是 | 表示被指定的回调方法 | | callback | 只读 | AsyncCallback\<string> | 是 | 返回当前进程的名称 |
- 返回值 - 返回值
...@@ -464,7 +471,7 @@ context.getProcessName() ...@@ -464,7 +471,7 @@ context.getProcessName()
#### Context.getProcessName() ## Context.getProcessName
- 接口说明 - 接口说明
...@@ -472,11 +479,13 @@ context.getProcessName() ...@@ -472,11 +479,13 @@ context.getProcessName()
- 参数描述 - 参数描述
Null
- 返回值 - 返回值
void | 类型 | 说明 |
| --------------- | -------------- |
| Promise<string> | 当前进程的名称 |
- 示例 - 示例
...@@ -490,17 +499,17 @@ context.getProcessName().then((void) => { ...@@ -490,17 +499,17 @@ context.getProcessName().then((void) => {
#### Context.getCallingBundle(callback: AsyncCallback\<string>) ## Context.getCallingBundle(callback: AsyncCallback<string>)
- 接口说明 - 接口说明
获取调用当前能力的能力的捆绑包名称(callback形式) 获取调用当前ability捆绑包名称(callback形式)
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ---------------------- | ---- | -------------------- | | -------- | -------- | ---------------------- | ---- | ------------------------- |
| callback | 只读 | AsyncCallback\<string> | 是 | 表示被指定的回调方法 | | callback | 只读 | AsyncCallback\<string> | 是 | 返回当前ability捆绑包名称 |
- 返回值 - 返回值
...@@ -516,19 +525,23 @@ context.getCallingBundle() ...@@ -516,19 +525,23 @@ context.getCallingBundle()
#### Context.getCallingBundle() ## Context.getCallingBundle
- 接口说明 - 接口说明
获取调用当前能力的能力的捆绑包名称(Promise形式) 获取调用当前ability捆绑包名称(Promise形式)
- 参数描述 - 参数描述
Null
- 返回值 - 返回值
void | 类型 | 说明 |
| --------------- | ------------------------- |
| Promise<string> | 调用当前ability捆绑包名称 |
- 示例 - 示例
......
### DataUriUtils模块(JS端SDK接口) # DataUriUtils模块
#### 权限列表 ## 导入模块
ohos.permission.RUNNING_LOCK permission
#### 导入模块
```js ```js
import notify from '@ohos.ability.dataUriUtils'; import dataUriUtils from '@ohos.ability.dataUriUtils';
``` ```
#### DataUriUtils.getId(uri: string) ## DataUriUtils.getId
- 接口说明 - 接口说明
...@@ -36,7 +32,7 @@ dataUriUtils.getIdSync("com.example.dataUriUtils/1221") ...@@ -36,7 +32,7 @@ dataUriUtils.getIdSync("com.example.dataUriUtils/1221")
#### DataUriUtils.attachId(uri: string, id: number) ## DataUriUtils.attachId
- 接口说明 - 接口说明
...@@ -67,7 +63,7 @@ dataUriUtils.attachId( ...@@ -67,7 +63,7 @@ dataUriUtils.attachId(
#### DataUriUtils.deleteId(uri: string) ## DataUriUtils.deleteId
- 接口说明 - 接口说明
...@@ -92,7 +88,7 @@ dataUriUtils.deleteId("com.example.dataUriUtils/1221") ...@@ -92,7 +88,7 @@ dataUriUtils.deleteId("com.example.dataUriUtils/1221")
#### DataUriUtils.updateId(uri: string, id: number) ## DataUriUtils.updateId
- 接口说明 - 接口说明
......
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
| DataAbilityHelper.query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\<ResultSet>) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | | DataAbilityHelper.query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\<ResultSet>) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |
| DataAbilityHelper.query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 | | DataAbilityHelper.query(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |
#### 权限列表
ohos.permission.RUNNING_LOCK permission
#### 导入模块 #### 导入模块
``` ```
...@@ -64,14 +60,16 @@ import ohos_data_rdb from '@ohos.data.rdb' ...@@ -64,14 +60,16 @@ import ohos_data_rdb from '@ohos.data.rdb'
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var mode = "rwt"; var mode = "rwt";
DAHelper.openFile( DAHelper.openFile(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
mode, mode,
) (err) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.openFile(uri: string, mode: string) #### DataAbilityHelper.openFile(uri: string, mode: string)
...@@ -95,7 +93,7 @@ DAHelper.openFile( ...@@ -95,7 +93,7 @@ DAHelper.openFile(
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var mode = "rwt"; var mode = "rwt";
...@@ -128,12 +126,16 @@ DAHelper.openFile( ...@@ -128,12 +126,16 @@ DAHelper.openFile(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var helper = await featureAbility.getDataAbilityHelper( var helper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
function onChangeNotify() {
console.info("==========================>onChangeNotify=======================>");
};
helper.on( helper.on(
"dataChange", "dataChange",
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
onChangeNotify
) )
``` ```
...@@ -159,13 +161,21 @@ helper.on( ...@@ -159,13 +161,21 @@ helper.on(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var helper = await featureAbility.getDataAbilityHelper( var helper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
function onChangeNotify() {
console.info("==========================>onChangeNotify=======================>");
};
helper.off( helper.off(
"dataChange", "dataChange",
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
) )
helper.off(
"dataChange",
"dataability:///com.example.DataAbility",
onChangeNotify
)
``` ```
#### DataAbilityHelper.getType(uri: string, callback: AsyncCallback\<string>) #### DataAbilityHelper.getType(uri: string, callback: AsyncCallback\<string>)
...@@ -189,12 +199,14 @@ helper.off( ...@@ -189,12 +199,14 @@ helper.off(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.getType( DAHelper.getType(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility",
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.getType(uri: string) #### DataAbilityHelper.getType(uri: string)
...@@ -217,12 +229,12 @@ DAHelper.getType( ...@@ -217,12 +229,12 @@ DAHelper.getType(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.getType( DAHelper.getType(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
).then((void) => { ).then((data) => {
console.info("==========================>getTypeCallback=======================>"); console.info("==========================>getTypeCallback=======================>");
}); });
``` ```
...@@ -236,10 +248,10 @@ DAHelper.getType( ...@@ -236,10 +248,10 @@ DAHelper.getType(
- 参数描述 - 参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 | | 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------------- | -------- | ---------------------- | ---- | ---------------------------- | | -------------- | -------- | ------------------------------ | ---- | ---------------------------- |
| uri | 只读 | string | 是 | 指示要获取的文件的路径。 | | uri | 只读 | string | 是 | 指示要获取的文件的路径。 |
| mimeTypeFilter | 只读 | string | 是 | 指示要获取的文件的MIME类型。 | | mimeTypeFilter | 只读 | string | 是 | 指示要获取的文件的MIME类型。 |
| callback | 只读 | AsyncCallback\<string> | 是 | 回调方法 | | callback | 只读 | AsyncCallback\<Array\<string>> | 是 | 回调方法 |
- 返回值 - 返回值
...@@ -249,13 +261,15 @@ DAHelper.getType( ...@@ -249,13 +261,15 @@ DAHelper.getType(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.getFileTypes( DAHelper.getFileTypes(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
"image/*" "image/*",
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string) #### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string)
...@@ -279,13 +293,13 @@ DAHelper.getFileTypes( ...@@ -279,13 +293,13 @@ DAHelper.getFileTypes(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.getFileTypes( DAHelper.getFileTypes(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
"image/*" "image/*"
).then((void) => { ).then((data) => {
console.info("==========================>getFileTypesCallback=======================>"); console.info("==========================>getFileTypesCallback=======================>");
}); });
``` ```
...@@ -311,12 +325,14 @@ DAHelper.getFileTypes( ...@@ -311,12 +325,14 @@ DAHelper.getFileTypes(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.normalizeUri( DAHelper.normalizeUri(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.normalizeUri(uri: string) #### DataAbilityHelper.normalizeUri(uri: string)
...@@ -339,12 +355,12 @@ DAHelper.normalizeUri( ...@@ -339,12 +355,12 @@ DAHelper.normalizeUri(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.normalizeUri( DAHelper.normalizeUri(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
).then((void) => { ).then((data) => {
console.info("==========================>normalizeUriCallback=======================>"); console.info("==========================>normalizeUriCallback=======================>");
}); });
``` ```
...@@ -370,12 +386,14 @@ DAHelper.normalizeUri( ...@@ -370,12 +386,14 @@ DAHelper.normalizeUri(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.denormalizeUri( DAHelper.denormalizeUri(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",,
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.denormalizeUri(uri: string) #### DataAbilityHelper.denormalizeUri(uri: string)
...@@ -398,12 +416,12 @@ DAHelper.denormalizeUri( ...@@ -398,12 +416,12 @@ DAHelper.denormalizeUri(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.denormalizeUri( DAHelper.denormalizeUri(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
).then((void) => { ).then((data) => {
console.info("==========================>denormalizeUriCallback=======================>"); console.info("==========================>denormalizeUriCallback=======================>");
}); });
``` ```
...@@ -429,12 +447,14 @@ DAHelper.denormalizeUri( ...@@ -429,12 +447,14 @@ DAHelper.denormalizeUri(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var helper = await featureAbility.getDataAbilityHelper( var helper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
helper.notifyChange( helper.notifyChange(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",,
) (err) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.notifyChange(uri: string) #### DataAbilityHelper.notifyChange(uri: string)
...@@ -457,7 +477,7 @@ helper.notifyChange( ...@@ -457,7 +477,7 @@ helper.notifyChange(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
DAHelper.notifyChange( DAHelper.notifyChange(
...@@ -489,7 +509,7 @@ DAHelper.notifyChange( ...@@ -489,7 +509,7 @@ DAHelper.notifyChange(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
const valueBucket = { const valueBucket = {
...@@ -500,8 +520,10 @@ const valueBucket = { ...@@ -500,8 +520,10 @@ const valueBucket = {
} }
DAHelper.insert( DAHelper.insert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
valueBucket valueBucket,
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket) #### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket)
...@@ -525,7 +547,7 @@ DAHelper.insert( ...@@ -525,7 +547,7 @@ DAHelper.insert(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
const valueBucket = { const valueBucket = {
...@@ -537,7 +559,7 @@ const valueBucket = { ...@@ -537,7 +559,7 @@ const valueBucket = {
DAHelper.insert( DAHelper.insert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
valueBucket valueBucket
).then((void) => { ).then((data) => {
console.info("==========================>insertCallback=======================>"); console.info("==========================>insertCallback=======================>");
}); });
``` ```
...@@ -564,7 +586,7 @@ DAHelper.insert( ...@@ -564,7 +586,7 @@ DAHelper.insert(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,},
...@@ -572,8 +594,10 @@ var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8 ...@@ -572,8 +594,10 @@ var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) {"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,})
DAHelper.batchInsert( DAHelper.batchInsert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
cars cars,
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>) #### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>)
...@@ -597,7 +621,7 @@ DAHelper.batchInsert( ...@@ -597,7 +621,7 @@ DAHelper.batchInsert(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,},
...@@ -606,7 +630,7 @@ var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8 ...@@ -606,7 +630,7 @@ var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8
DAHelper.batchInsert( DAHelper.batchInsert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
cars cars
).then((void) => { ).then((data) => {
console.info("==========================>batchInsertCallback=======================>"); console.info("==========================>batchInsertCallback=======================>");
}); });
``` ```
...@@ -634,14 +658,16 @@ DAHelper.batchInsert( ...@@ -634,14 +658,16 @@ DAHelper.batchInsert(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability' import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
let da = new ohos_data_ability.DataAbilityPredicates() let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.delete( DAHelper.delete(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
da da,
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates) #### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates)
...@@ -665,14 +691,14 @@ DAHelper.delete( ...@@ -665,14 +691,14 @@ DAHelper.delete(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
let da = new ohos_data_ability.DataAbilityPredicates() let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.delete( DAHelper.delete(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
da da
).then((void) => { ).then((data) => {
console.info("==========================>deleteCallback=======================>"); console.info("==========================>deleteCallback=======================>");
}); });
``` ```
...@@ -701,7 +727,7 @@ DAHelper.delete( ...@@ -701,7 +727,7 @@ DAHelper.delete(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability' import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
const va = { const va = {
...@@ -714,8 +740,10 @@ let da = new ohos_data_ability.DataAbilityPredicates() ...@@ -714,8 +740,10 @@ let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.update( DAHelper.update(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
va, va,
da da,
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
#### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates) #### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates)
...@@ -741,7 +769,7 @@ DAHelper.update( ...@@ -741,7 +769,7 @@ DAHelper.update(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability' import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
const va = { const va = {
...@@ -755,7 +783,7 @@ DAHelper.update( ...@@ -755,7 +783,7 @@ DAHelper.update(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
va, va,
da da
).then((void) => { ).then((data) => {
console.info("==========================>updateCallback=======================>"); console.info("==========================>updateCallback=======================>");
}); });
``` ```
...@@ -784,7 +812,7 @@ DAHelper.update( ...@@ -784,7 +812,7 @@ DAHelper.update(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability' import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"}); var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"});
...@@ -792,8 +820,10 @@ let da = new ohos_data_ability.DataAbilityPredicates() ...@@ -792,8 +820,10 @@ let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.query( DAHelper.query(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
cars, cars,
da da,
) (err, data) => {
console.info("==========================>Called=======================>");
});
``` ```
...@@ -821,7 +851,7 @@ DAHelper.query( ...@@ -821,7 +851,7 @@ DAHelper.query(
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability' import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = await featureAbility.getDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"}); var cars=new Array({"value1"}, {"value2"}, {"value3"}, {"value4"});
...@@ -830,8 +860,7 @@ DAHelper.query( ...@@ -830,8 +860,7 @@ DAHelper.query(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
cars, cars,
da da
).then((void) => { ).then((data) => {
console.info("==========================>queryCallback=======================>"); console.info("==========================>queryCallback=======================>");
}); });
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册