Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ba3112c1
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba3112c1
编写于
12月 31, 2021
作者:
X
xuchenghua09
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update js-apis
Signed-off-by:
N
xuchenghua09
<
xuchenghua09@huawei.com
>
上级
0a6d3fe9
变更
7
展开全部
显示空白变更内容
内联
并排
Showing
7 changed file
with
3794 addition
and
3645 deletion
+3794
-3645
zh-cn/application-dev/reference/apis/js-apis-Context.md
zh-cn/application-dev/reference/apis/js-apis-Context.md
+555
-542
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md
+118
-122
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
+910
-508
zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md
...plication-dev/reference/apis/js-apis-dataAbilityHelper.md
+866
-837
zh-cn/application-dev/reference/apis/js-apis-featureAbility.md
.../application-dev/reference/apis/js-apis-featureAbility.md
+702
-963
zh-cn/application-dev/reference/apis/js-apis-notification.md
zh-cn/application-dev/reference/apis/js-apis-notification.md
+249
-262
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
...application-dev/reference/apis/js-apis-particleAbility.md
+394
-411
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-Context.md
浏览文件 @
ba3112c1
# Context模块
(JS端SDK接口)
# Context模块
##
## 支持设备
##
支持设备
| API | 手机 | 平板 | 智慧屏 | 智能穿戴 | 轻量级智能穿戴 | 智慧视觉设备 |
| ------------------------------------------------------------ | ---- | ---- | ------ | -------- | -------------- | ------------ |
...
...
@@ -23,18 +23,22 @@
| Context.getCallingBundle(callback: AsyncCallback
\<
string>) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |
| 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 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'
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ----------------------
- | ---- | ---------------- |
| callback | 只读 | AsyncCallback
\<
string>
) | 是 | 被指定的回调方法 |
| -------- | -------- | ----------------------
| ---- | ------------------------ |
| callback | 只读 | AsyncCallback
\<
string>
| 是 | 返回应用程序的本地根目录 |
-
返回值
根目录
void
-
示例
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
()
context
.
getOrCreateLocalDir
((
err
,
data
)
=>
{
console
.
info
(
"
data=
"
+
data
);
})
```
##
## Context.getOrCreateLocalDir()
##
Context.getOrCreateLocalDir()
-
接口说明
...
...
@@ -69,7 +75,9 @@ context.getOrCreateLocalDir()
-
返回值
根目录
| 类型 | 说明 |
| --------------- | -------------------- |
| Promise
<string>
| 应用程序的本地根目录 |
-
示例
...
...
@@ -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形式)
-
verifyPermission参数描述
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---------- | -------- | ----------------------
| ---- | ---------------- |
| ---------- | -------- | ----------------------
------------------------- | ---- | ----------------------------------- |
| permission | 只读 | string | 是 | 指定权限的名称 |
| options | 只读 | PermissionOptions | 是 | 进程id |
| callback | 只读 | AsyncCallback
\<
number> | 是 | 被指定的回调方法 |
-
PermissionOptions类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---- | -------- | ------ | ---- | ------ |
| pid | 只读 | number | 否 | 进程id |
| uid | 只读 | number | 否 | 用户id |
| options | 只读 |
[
PermissionOptions
](
#PermissionOptions类型说明
)
| 是 | 进程id |
| callback | 只读 | AsyncCallback
\<
number> | 是 | 返回权限验证结果,0有权限,-1无权限 |
-
返回值
如果PID和UID具有权限,则使用{@code 0}进行异步回调;否则使用{@code-1}回调。
void
-
示例
...
...
@@ -116,29 +122,29 @@ import featureAbility from '@ohos.ability.featureAbility'
import
bundle
from
'
@ohos.bundle
'
var
context
=
featureAbility
.
getContext
();
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 | 是 | 指定权限的名称 |
| callback | 只读 | AsyncCallback
\<
number>
) | 是 | 被指定的回调方法 |
| callback | 只读 | AsyncCallback
\<
number>
| 是 | 返回权限验证结果,0有权限,-1无权限 |
-
返回值
如果PID和UID具有权限,则使用{@code 0}进行异步回调;否则使用{@code-1}回调。
void
-
示例
...
...
@@ -150,29 +156,24 @@ context.verifyPermission("com.example.permission")
##
## Context.verifyPermission(permission: string, options?: PermissionOptions)
##
Context.verifyPermission(permission: string, options?: PermissionOptions)
-
接口说明
验证系统中运行的特定pid和uid是否
允许指定的权限(Promise形式)
-
verifyPermission参数描述
验证系统中运行的特定pid和uid是否
具有指定的权限(Promise形式)
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---------- | -------- | -----------------
| ---- | -------------- |
| ---------- | -------- | -----------------
------------------------------ | ---- | -------------- |
| permission | 只读 | string | 是 | 指定权限的名称 |
| options | 只读 | PermissionOptions | 否 | 进程id |
-
PermissionOptions类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ---- | -------- | ------ | ---- | ------ |
| pid | 只读 | number | 否 | 进程id |
| uid | 只读 | number | 否 | 用户id |
| options | 只读 |
[
PermissionOptions
](
#PermissionOptions类型说明
)
| 否 | 进程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) =>
});
```
## 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) =>
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------------- | -------- | ----------------------------------------
| ---- | --------------------------------------------- |
| -------------- | -------- | ----------------------------------------
-------------------- | ---- | --------------------------------------------- |
| permissions | 只读 | Array
\<
string> | 是 | 指示要请求的权限列表。此参数不能为null |
| requestCode | 只读 | number | 是 | 指示要传递给PermissionRequestResult的请求代码 |
| resultCallback | 只读 | AsyncCallback
\<
PermissionRequestResult>) | 是 | 被指定的回调方法 |
-
PermissionRequestResult类型说明
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | 只读 | number | 是 | 用户传入的请求代码 |
| permissions | 只读 | Array
\<
string> | 是 | 用户传入的权限 |
| authResults | 只读 | Array
\<
number> | 是 | 求权限的结果 |
| resultCallback | 只读 | AsyncCallback
\<
[
PermissionRequestResult
](
#PermissionRequestResult类型说明
)
> | 是 | 返回授权结果信息 |
-
返回值
void
...
...
@@ -230,7 +231,7 @@ context.getOrCreateLocalDir(
##
## Context.getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>)
##
Context.getApplicationInfo(callback: AsyncCallback<ApplicationInfo>)
-
接口说明
...
...
@@ -239,8 +240,8 @@ context.getOrCreateLocalDir(
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ------------------------------- | ---- | --------------------
|
| callback | 只读 | AsyncCallback
\<
ApplicationInfo> | 是 |
表示被指定的回调方法 |
| -------- | -------- | ------------------------------- | ---- | --------------------
-- |
| callback | 只读 | AsyncCallback
\<
ApplicationInfo> | 是 |
返回当前应用程序的信息 |
-
返回值
...
...
@@ -256,7 +257,7 @@ context.getApplicationInfo()
##
## Context.getApplicationInfo()
##
Context.getApplicationInfo
-
接口说明
...
...
@@ -264,11 +265,13 @@ context.getApplicationInfo()
-
参数描述
Null
无
-
返回值
void
| 类型 | 说明 |
| ------------------------ | ------------------ |
| Promise
<ApplicationInfo>
| 当前应用程序的信息 |
-
示例
...
...
@@ -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) => {
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ---------------------- | ---- | --------------------
|
| callback | 只读 | AsyncCallback
\<
string> | 是 |
表示被指定的回调方法 |
| -------- | -------- | ---------------------- | ---- | --------------------
------- |
| callback | 只读 | AsyncCallback
\<
string> | 是 |
返回当前ability的捆绑包名称 |
-
返回值
...
...
@@ -308,7 +311,7 @@ context.getBundleName()
##
## Context.getBundleName()
##
Context.getBundleName
-
接口说明
...
...
@@ -316,11 +319,13 @@ context.getBundleName()
-
参数描述
Null
无
-
返回值
void
| 类型 | 说明 |
| --------------- | ----------------------- |
| Promise
<string>
| 当前ability的捆绑包名称 |
-
示例
...
...
@@ -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) => {
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | --------------------------- | ---- | ------------------
-- |
| callback | 只读 | AsyncCallback
\<
ProcessInfo> | 是 |
表示被指定的回调方法 |
| -------- | -------- | --------------------------- | ---- | ------------------
|
| callback | 只读 | AsyncCallback
\<
ProcessInfo> | 是 |
返回当前进程的信息 |
-
返回值
...
...
@@ -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) => {
##
## 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()
##
## Context.getElementName()
##
Context.getElementName
-
接口说明
...
...
@@ -420,11 +427,13 @@ context.getElementName()
-
参数描述
Null
无
-
返回值
void
| 类型 | 说明 |
| -------------------- | ---------------------------------------- |
| Promise
<ElementName>
| 当前ability的ohos.bundle.ElementName对象 |
-
示例
...
...
@@ -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) => {
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------- | -------- | ---------------------- | ---- | ------------------
-- |
| callback | 只读 | AsyncCallback
\<
string> | 是 |
表示被指定的回调方法 |
| -------- | -------- | ---------------------- | ---- | ------------------
|
| callback | 只读 | AsyncCallback
\<
string> | 是 |
返回当前进程的名称 |
-
返回值
...
...
@@ -464,7 +471,7 @@ context.getProcessName()
##
## Context.getProcessName()
##
Context.getProcessName
-
接口说明
...
...
@@ -472,11 +479,13 @@ context.getProcessName()
-
参数描述
Null
无
-
返回值
void
| 类型 | 说明 |
| --------------- | -------------- |
| Promise
<string>
| 当前进程的名称 |
-
示例
...
...
@@ -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()
##
## Context.getCallingBundle()
##
Context.getCallingBundle
-
接口说明
获取调用当前
能力的能力的捆绑包名称(Promise形式)
获取调用当前
ability捆绑包名称(Promise形式)
-
参数描述
Null
无
-
返回值
void
| 类型 | 说明 |
| --------------- | ------------------------- |
| Promise
<string>
| 调用当前ability捆绑包名称 |
-
示例
...
...
zh-cn/application-dev/reference/apis/js-apis-DataUriUtils.md
浏览文件 @
ba3112c1
#
## DataUriUtils模块(JS端SDK接口)
#
DataUriUtils模块
#### 权限列表
ohos.permission.RUNNING_LOCK permission
#### 导入模块
## 导入模块
```
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")
##
## DataUriUtils.attachId(uri: string, id: number)
##
DataUriUtils.attachId
-
接口说明
...
...
@@ -67,7 +63,7 @@ dataUriUtils.attachId(
##
## DataUriUtils.deleteId(uri: string)
##
DataUriUtils.deleteId
-
接口说明
...
...
@@ -92,7 +88,7 @@ dataUriUtils.deleteId("com.example.dataUriUtils/1221")
##
## DataUriUtils.updateId(uri: string, id: number)
##
DataUriUtils.updateId
-
接口说明
...
...
zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
浏览文件 @
ba3112c1
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-dataAbilityHelper.md
浏览文件 @
ba3112c1
...
...
@@ -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) | 支持 | 支持 | 支持 | 支持 | 不支持 | 不支持 |
#### 权限列表
ohos.permission.RUNNING_LOCK permission
#### 导入模块
```
...
...
@@ -64,14 +60,16 @@ import ohos_data_rdb from '@ohos.data.rdb'
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
mode
=
"
rwt
"
;
DAHelper
.
openFile
(
"
dataability:///com.example.DataAbility
"
,
mode
,
)
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.openFile(uri: string, mode: string)
...
...
@@ -95,7 +93,7 @@ DAHelper.openFile(
```
javascript
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
mode
=
"
rwt
"
;
...
...
@@ -128,12 +126,16 @@ DAHelper.openFile(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
helper
=
await
featureAbility
.
getDataAbilityHelper
(
var
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
function
onChangeNotify
()
{
console
.
info
(
"
==========================>onChangeNotify=======================>
"
);
};
helper
.
on
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
onChangeNotify
)
```
...
...
@@ -159,13 +161,21 @@ helper.on(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
helper
=
await
featureAbility
.
getDataAbilityHelper
(
var
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
function
onChangeNotify
()
{
console
.
info
(
"
==========================>onChangeNotify=======================>
"
);
};
helper
.
off
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
)
helper
.
off
(
"
dataChange
"
,
"
dataability:///com.example.DataAbility
"
,
onChangeNotify
)
```
#### DataAbilityHelper.getType(uri: string, callback: AsyncCallback\<string>)
...
...
@@ -189,12 +199,14 @@ helper.off(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getType
(
"
dataability:///com.example.DataAbility
"
)
"
dataability:///com.example.DataAbility
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.getType(uri: string)
...
...
@@ -217,12 +229,12 @@ DAHelper.getType(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getType
(
"
dataability:///com.example.DataAbility
"
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getTypeCallback=======================>
"
);
});
```
...
...
@@ -236,10 +248,10 @@ DAHelper.getType(
-
参数描述
| 名称 | 读写属性 | 类型 | 必填 | 描述 |
| -------------- | -------- | ----------------------
| ---- | ---------------------------- |
| -------------- | -------- | ----------------------
-------- | ---- | ---------------------------- |
| uri | 只读 | string | 是 | 指示要获取的文件的路径。 |
| mimeTypeFilter | 只读 | string | 是 | 指示要获取的文件的MIME类型。 |
| callback | 只读 | AsyncCallback
\<
string> | 是 | 回调方法 |
| callback | 只读 | AsyncCallback
\<
Array
\<
string>> | 是 | 回调方法 |
-
返回值
...
...
@@ -249,13 +261,15 @@ DAHelper.getType(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getFileTypes
(
"
dataability:///com.example.DataAbility
"
,
"
image/*
"
)
"
image/*
"
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.getFileTypes(uri: string, mimeTypeFilter: string)
...
...
@@ -279,13 +293,13 @@ DAHelper.getFileTypes(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
getFileTypes
(
"
dataability:///com.example.DataAbility
"
,
"
image/*
"
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>getFileTypesCallback=======================>
"
);
});
```
...
...
@@ -311,12 +325,14 @@ DAHelper.getFileTypes(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
normalizeUri
(
"
dataability:///com.example.DataAbility
"
,
)
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.normalizeUri(uri: string)
...
...
@@ -339,12 +355,12 @@ DAHelper.normalizeUri(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
normalizeUri
(
"
dataability:///com.example.DataAbility
"
,
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>normalizeUriCallback=======================>
"
);
});
```
...
...
@@ -370,12 +386,14 @@ DAHelper.normalizeUri(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,
)
"
dataability:///com.example.DataAbility
"
,,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.denormalizeUri(uri: string)
...
...
@@ -398,12 +416,12 @@ DAHelper.denormalizeUri(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
denormalizeUri
(
"
dataability:///com.example.DataAbility
"
,
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>denormalizeUriCallback=======================>
"
);
});
```
...
...
@@ -429,12 +447,14 @@ DAHelper.denormalizeUri(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
helper
=
await
featureAbility
.
getDataAbilityHelper
(
var
helper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
helper
.
notifyChange
(
"
dataability:///com.example.DataAbility
"
,
)
"
dataability:///com.example.DataAbility
"
,,
(
err
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.notifyChange(uri: string)
...
...
@@ -457,7 +477,7 @@ helper.notifyChange(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
DAHelper
.
notifyChange
(
...
...
@@ -489,7 +509,7 @@ DAHelper.notifyChange(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
valueBucket
=
{
...
...
@@ -500,8 +520,10 @@ const valueBucket = {
}
DAHelper
.
insert
(
"
dataability:///com.example.DataAbility
"
,
valueBucket
)
valueBucket
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.insert(uri: string, valuesBucket: rdb.ValuesBucket)
...
...
@@ -525,7 +547,7 @@ DAHelper.insert(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
valueBucket
=
{
...
...
@@ -537,7 +559,7 @@ const valueBucket = {
DAHelper
.
insert
(
"
dataability:///com.example.DataAbility
"
,
valueBucket
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>insertCallback=======================>
"
);
});
```
...
...
@@ -564,7 +586,7 @@ DAHelper.insert(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
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
,})
DAHelper
.
batchInsert
(
"
dataability:///com.example.DataAbility
"
,
cars
)
cars
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.batchInsert(uri: string, valuesBuckets: Array<rdb.ValuesBucket>)
...
...
@@ -597,7 +621,7 @@ DAHelper.batchInsert(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
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
(
"
dataability:///com.example.DataAbility
"
,
cars
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>batchInsertCallback=======================>
"
);
});
```
...
...
@@ -634,14 +658,16 @@ DAHelper.batchInsert(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataability
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
delete
(
"
dataability:///com.example.DataAbility
"
,
da
)
da
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.delete(uri: string, predicates: dataAbility.DataAbilityPredicates)
...
...
@@ -665,14 +691,14 @@ DAHelper.delete(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
let
da
=
new
ohos_data_ability
.
DataAbilityPredicates
()
DAHelper
.
delete
(
"
dataability:///com.example.DataAbility
"
,
da
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>deleteCallback=======================>
"
);
});
```
...
...
@@ -701,7 +727,7 @@ DAHelper.delete(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataability
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
va
=
{
...
...
@@ -714,8 +740,10 @@ let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper
.
update
(
"
dataability:///com.example.DataAbility
"
,
va
,
da
)
da
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
#### DataAbilityHelper.update(uri: string, valuesBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates)
...
...
@@ -741,7 +769,7 @@ DAHelper.update(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataability
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
const
va
=
{
...
...
@@ -755,7 +783,7 @@ DAHelper.update(
"
dataability:///com.example.DataAbility
"
,
va
,
da
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>updateCallback=======================>
"
);
});
```
...
...
@@ -784,7 +812,7 @@ DAHelper.update(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataability
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
cars
=
new
Array
({
"
value1
"
},
{
"
value2
"
},
{
"
value3
"
},
{
"
value4
"
});
...
...
@@ -792,8 +820,10 @@ let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper
.
query
(
"
dataability:///com.example.DataAbility
"
,
cars
,
da
)
da
,
(
err
,
data
)
=>
{
console
.
info
(
"
==========================>Called=======================>
"
);
});
```
...
...
@@ -821,7 +851,7 @@ DAHelper.query(
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
import
ohos_data_ability
from
'
@ohos.data.dataability
'
var
DAHelper
=
await
featureAbility
.
getDataAbilityHelper
(
var
DAHelper
=
featureAbility
.
acquireDataAbilityHelper
(
"
dataability:///com.example.DataAbility
"
);
var
cars
=
new
Array
({
"
value1
"
},
{
"
value2
"
},
{
"
value3
"
},
{
"
value4
"
});
...
...
@@ -830,8 +860,7 @@ DAHelper.query(
"
dataability:///com.example.DataAbility
"
,
cars
,
da
).
then
((
void
)
=>
{
).
then
((
data
)
=>
{
console
.
info
(
"
==========================>queryCallback=======================>
"
);
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-featureAbility.md
浏览文件 @
ba3112c1
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-notification.md
浏览文件 @
ba3112c1
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
浏览文件 @
ba3112c1
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录