Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
11033ea0
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看板
未验证
提交
11033ea0
编写于
7月 19, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6873 【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md.
Merge pull request !6873 from 葛亚芳/N/A
上级
1bb70061
3ee55075
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
3 deletion
+26
-3
zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md
.../application-dev/reference/apis/js-apis-data-dataShare.md
+26
-3
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md
浏览文件 @
11033ea0
...
...
@@ -10,7 +10,6 @@
## 导入模块
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataShare
from
'
@ohos.data.dataShare
'
```
...
...
@@ -34,7 +33,7 @@ createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<
**示例:**
```
ts
import
dataShare
from
'
@ohos.data.dataShare
'
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
dataShareHelper
;
...
...
@@ -72,7 +71,7 @@ createDataShareHelper(context: Context, uri: string): Promise<DataShareHelper
**示例:**
```
ts
import
dataShare
from
'
@ohos.data.dataShare
'
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
dataShareHelper
;
...
...
@@ -109,6 +108,7 @@ openFile(uri: string, mode: string, callback: AsyncCallback<number>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
openFile
(
uri
,
"
rwt
"
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -146,6 +146,7 @@ openFile(uri: string, mode: string): Promise<number>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
openFile
(
uri
,
"
rwt
"
).
then
((
data
)
=>
{
console
.
info
(
"
openFile succeed, data :
"
+
data
);
...
...
@@ -176,6 +177,7 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
function
onCallback
()
{
console
.
info
(
"
**** Observer on callback ****
"
);
}
...
...
@@ -204,6 +206,7 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
function
offCallback
()
{
console
.
info
(
"
**** Observer off callback ****
"
);
}
...
...
@@ -232,6 +235,7 @@ insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>):
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
const
valueBucket
=
{
"
name
"
:
"
rose
"
,
...
...
@@ -273,6 +277,7 @@ insert(uri: string, value: ValuesBucket): Promise<number>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
const
valueBucket
=
{
"
name
"
:
"
rose1
"
,
...
...
@@ -307,6 +312,7 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callbac
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
...
...
@@ -347,6 +353,7 @@ delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promis
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
...
...
@@ -381,6 +388,7 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns:
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
...
...
@@ -423,6 +431,7 @@ query(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns:
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
...
...
@@ -458,6 +467,7 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value:
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
...
...
@@ -505,6 +515,7 @@ update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value:
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
...
...
@@ -544,6 +555,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallb
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
vbs
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
...
...
@@ -583,6 +595,7 @@ batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number&g
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
vbs
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
...
...
@@ -614,6 +627,7 @@ getType(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
getType
(
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -650,6 +664,7 @@ getType(uri: string): Promise<string>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
getType
(
uri
).
then
((
data
)
=>
{
console
.
log
(
"
getType succeed, data :
"
+
data
);
...
...
@@ -679,6 +694,7 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Arr
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
mimeTypeFilter
=
"
image/*
"
;
dataShareHelper
.
getFileTypes
(
uri
,
mimeTypeFilter
,
(
err
,
data
)
=>
{
...
...
@@ -716,6 +732,7 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise<Array<string>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
mimeTypeFilter
=
"
image/*
"
;
dataShareHelper
.
getFileTypes
(
uri
,
mimeTypeFilter
).
then
((
data
)
=>
{
...
...
@@ -745,6 +762,7 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
normalizeUri
(
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -780,6 +798,7 @@ normalizeUri(uri: string): Promise<string>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
normalizeUri
(
uri
).
then
((
data
)
=>
{
console
.
log
(
"
normalizeUri =
"
+
data
);
...
...
@@ -808,6 +827,7 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
denormalizeUri
(
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -843,6 +863,7 @@ denormalizeUri(uri: string): Promise<string>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
denormalizeUri
(
uri
).
then
((
data
)
=>
{
console
.
log
(
"
denormalizeUri =
"
+
data
);
...
...
@@ -871,6 +892,7 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
notifyChange
(
uri
,
()
=>
{
console
.
log
(
"
***** notifyChange *****
"
);
...
...
@@ -902,6 +924,7 @@ notifyChange(uri: string): Promise<void>
**示例:**
```
ts
import
Ability
from
'
@ohos.application.Ability
'
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
notifyChange
(
uri
);
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录