未验证 提交 11033ea0 编写于 作者: O openharmony_ci 提交者: Gitee

!6873 【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md.

Merge pull request !6873 from 葛亚芳/N/A
......@@ -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&gt
**示例:**
```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.
先完成此消息的编辑!
想要评论请 注册