Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2661d914
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看板
未验证
提交
2661d914
编写于
9月 06, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 06, 2023
浏览文件
操作
浏览文件
下载
差异文件
!24063 dataShare相关使用说明文档示例代码ArxTs规范整改
Merge pull request !24063 from 刘赛美/monthly_20230815
上级
1e13468f
89031f65
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
454 addition
and
372 deletion
+454
-372
zh-cn/application-dev/database/share-data-by-datashareextensionability.md
...n-dev/database/share-data-by-datashareextensionability.md
+37
-35
zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
...nce/apis/js-apis-application-dataShareExtensionAbility.md
+69
-84
zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md
...ion-dev/reference/apis/js-apis-data-DataShareResultSet.md
+73
-43
zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md
.../application-dev/reference/apis/js-apis-data-dataShare.md
+275
-210
未找到文件。
zh-cn/application-dev/database/share-data-by-datashareextensionability.md
浏览文件 @
2661d914
...
...
@@ -60,36 +60,34 @@
3.
在DataShareExtAbility.ts文件中,导入
`@ohos.application.DataShareExtensionAbility`
模块,开发者可根据应用需求选择性重写其业务实现。例如数据提供方只提供插入、删除和查询服务,则可只重写这些接口,并导入对应的基础依赖模块。
```
j
s
```
t
s
import
Extension
from
'
@ohos.application.DataShareExtensionAbility
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
relationalStore
from
'
@ohos.data.relationalStore
'
;
import
Want
from
'
@ohos.app.ability.Want
'
;
import
{
BusinessError
}
from
'
@ohos.base
'
```
4.
数据提供方的业务实现由开发者自定义。例如可以通过数据库、读写文件或访问网络等各方式实现数据提供方的数据存储。
```
j
s
```
t
s
const
DB_NAME
=
'
DB00.db
'
;
const
TBL_NAME
=
'
TBL00
'
;
const
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)
'
;
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
let
result
:
string
;
export
default
class
DataShareExtAbility
extends
Extension
{
private
rdbStore_
:
relationalStore
.
RdbStore
;
// 重写onCreate接口
onCreate
(
want
:
Want
,
callback
:
Function
)
{
result
=
this
.
context
.
cacheDir
+
'
/datashare.txt
'
;
// 业务实现使用RDB
r
db
.
getRdbStore
(
this
.
context
,
{
r
elationalStore
.
getRdbStore
(
this
.
context
,
{
name
:
DB_NAME
,
securityLevel
:
r
db
.
SecurityLevel
.
S1
securityLevel
:
r
elationalStore
.
SecurityLevel
.
S1
},
(
err
,
data
)
=>
{
rdbStore
=
data
;
rdbStore
.
executeSql
(
DDL_TBL_CREATE
,
[],
(
err
)
=>
{
...
...
@@ -100,7 +98,7 @@
}
});
}
// 重写query接口
query
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
columns
:
Array
<
string
>
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
...
...
@@ -116,7 +114,9 @@
}
});
}
catch
(
err
)
{
console
.
error
(
`Failed to query. Code:
${
err
.
code
}
,message:
${
err
.
message
}
`
);
let
code
=
(
err
as
BusinessError
).
code
;
let
message
=
(
err
as
BusinessError
).
message
console
.
error
(
`Failed to query. Code:
${
code
}
,message:
${
message
}
`
);
}
}
// 可根据应用需求,选择性重写各个接口
...
...
@@ -186,7 +186,7 @@
1.
导入基础依赖包。
```
j
s
```
t
s
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
dataShare
from
'
@ohos.data.dataShare
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
...
...
@@ -196,17 +196,17 @@
2.
定义与数据提供方通信的URI字符串。
```
j
s
```
t
s
// 作为参数传递的URI,与module.json5中定义的URI的区别是多了一个"/",是因为作为参数传递的URI中,在第二个与第三个"/"中间,存在一个DeviceID的参数
let
dseUri
=
(
'
datashareproxy://com.samples.datasharetest.DataShare
'
);
```
3.
创建工具接口类对象。
```
j
s
let
dsHelper
:
dataShare
.
DataShareHelper
;
```
t
s
let
dsHelper
:
dataShare
.
DataShareHelper
|
undefined
=
undefined
;
let
abilityContext
:
Context
;
export
default
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
)
{
abilityContext
=
this
.
context
;
...
...
@@ -219,7 +219,7 @@
4.
获取到接口类对象后,便可利用其提供的接口访问提供方提供的服务,如进行数据的增删改查等。
```
j
s
```
t
s
// 构建一条数据
let
key1
=
'
name
'
;
let
key2
=
'
age
'
;
...
...
@@ -236,22 +236,24 @@
let
updateBucket
:
ValuesBucket
=
{
key1
:
valueName2
,
key2
:
valueAge2
,
key3
:
valueIsStudent2
,
key4
:
valueBinary
};
let
predicates
=
new
dataSharePredicates
.
DataSharePredicates
();
let
valArray
=
[
'
*
'
];
// 插入一条数据
dsHelper
.
insert
(
dseUri
,
valuesBucket
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper insert result:
${
data
}
`
);
});
// 更新数据
dsHelper
.
update
(
dseUri
,
predicates
,
updateBucket
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper update result:
${
data
}
`
);
});
// 查询数据
dsHelper
.
query
(
dseUri
,
predicates
,
valArray
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper query result:
${
data
}
`
);
});
// 删除指定的数据
dsHelper
.
delete
(
dseUri
,
predicates
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper delete result:
${
data
}
`
);
});
if
(
dsHelper
!=
undefined
)
{
// 插入一条数据
(
dsHelper
as
dataShare
.
DataShareHelper
).
insert
(
dseUri
,
valuesBucket
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper insert result:
${
data
}
`
);
});
// 更新数据
(
dsHelper
as
dataShare
.
DataShareHelper
).
update
(
dseUri
,
predicates
,
updateBucket
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper update result:
${
data
}
`
);
});
// 查询数据
(
dsHelper
as
dataShare
.
DataShareHelper
).
query
(
dseUri
,
predicates
,
valArray
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper query result:
${
data
}
`
);
});
// 删除指定的数据
(
dsHelper
as
dataShare
.
DataShareHelper
).
delete
(
dseUri
,
predicates
,
(
err
,
data
)
=>
{
console
.
info
(
`dsHelper delete result:
${
data
}
`
);
});
}
```
## 相关实例
...
...
zh-cn/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
浏览文件 @
2661d914
...
...
@@ -43,31 +43,32 @@ DataShare客户端连接DataShareExtensionAbility服务端时,服务端回调
**示例:**
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
relationalStore
from
'
@ohos.data.relationalStore
'
import
Want
from
'
@ohos.app.ability.Want
'
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
onCreate
(
want
:
Want
,
callback
:
Function
)
{
rdb
.
getRdbStore
(
this
.
context
,
{
name
:
DB_NAME
,
securityLevel
:
rdb
.
SecurityLevel
.
S1
},
(
err
,
data
)
=>
{
console
.
info
(
`getRdbStore done, data :
${
data
}
`
);
rdbStore
=
data
;
rdbStore
.
executeSql
(
DDL_TBL_CREATE
,
[],
(
err
)
=>
{
console
.
error
(
`executeSql done, error message :
${
err
}
`
);
});
if
(
callback
)
{
callback
();
}
});
}
onCreate
(
want
:
Want
,
callback
:
Function
)
{
relationalStore
.
getRdbStore
(
this
.
context
,
{
name
:
DB_NAME
,
securityLevel
:
relationalStore
.
SecurityLevel
.
S1
},
(
err
,
data
)
=>
{
console
.
info
(
`getRdbStore done, data :
${
data
}
`
);
rdbStore
=
data
;
rdbStore
.
executeSql
(
DDL_TBL_CREATE
,
[],
(
err
)
=>
{
console
.
error
(
`executeSql done, error message :
${
err
}
`
);
});
if
(
callback
)
{
callback
();
}
});
}
};
```
...
...
@@ -90,29 +91,25 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe
**示例:**
```
ts
import
r
db
from
'
@ohos.data.relationalStore
'
;
import
r
elationalStore
from
'
@ohos.data.relationalStore
'
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
insert
(
uri
:
string
,
valueBucket
:
ValuesBucket
,
callback
:
Function
)
{
if
(
valueBucket
===
null
)
{
console
.
error
(
'
invalid valueBuckets
'
);
return
;
}
rdbStore
.
insert
(
TBL_NAME
,
valueBucket
,
(
err
,
ret
)
=>
{
console
.
info
(
`callback ret:
${
ret
}
`
);
if
(
callback
!==
undefined
)
{
callback
(
err
,
ret
);
}
});
insert
(
uri
:
string
,
valueBucket
:
ValuesBucket
,
callback
:
Function
)
{
if
(
valueBucket
===
null
)
{
console
.
error
(
'
invalid valueBuckets
'
);
return
;
}
rdbStore
.
insert
(
TBL_NAME
,
valueBucket
,
(
err
,
ret
)
=>
{
console
.
info
(
`callback ret:
${
ret
}
`
);
if
(
callback
!==
undefined
)
{
callback
(
err
,
ret
);
}
});
}
};
```
...
...
@@ -136,28 +133,24 @@ update?(uri: string, predicates: dataSharePredicates.DataSharePredicates, valueB
**示例:**
```
ts
import
r
db
from
'
@ohos.data.relationalStore
'
;
import
r
elationalStore
from
'
@ohos.data.relationalStore
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
update
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
valueBucket
:
ValuesBucket
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
return
;
}
rdbStore
.
update
(
TBL_NAME
,
valueBucket
,
predicates
,
(
err
,
ret
)
=>
{
if
(
callback
!==
undefined
)
{
callback
(
err
,
ret
);
}
});
update
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
valueBucket
:
ValuesBucket
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
return
;
}
rdbStore
.
update
(
TBL_NAME
,
valueBucket
,
predicates
,
(
err
,
ret
)
=>
{
if
(
callback
!==
undefined
)
{
callback
(
err
,
ret
);
}
});
}
};
```
...
...
@@ -180,27 +173,23 @@ delete?(uri: string, predicates: dataSharePredicates.DataSharePredicates, callba
**示例:**
```
ts
import
r
db
from
'
@ohos.data.relationalStore
'
;
import
r
elationalStore
from
'
@ohos.data.relationalStore
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
delete
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
return
;
}
rdbStore
.
delete
(
TBL_NAME
,
predicates
,
(
err
,
ret
)
=>
{
if
(
callback
!==
undefined
)
{
callback
(
err
,
ret
);
}
});
delete
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
return
;
}
rdbStore
.
delete
(
TBL_NAME
,
predicates
,
(
err
,
ret
)
=>
{
if
(
callback
!==
undefined
)
{
callback
(
err
,
ret
);
}
});
}
};
```
...
...
@@ -224,30 +213,26 @@ query?(uri: string, predicates: dataSharePredicates.DataSharePredicates, columns
**示例:**
```
ts
import
r
db
from
'
@ohos.data.relationalStore
'
;
import
r
elationalStore
from
'
@ohos.data.relationalStore
'
;
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
query
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
columns
:
Array
<
string
>
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
return
;
}
rdbStore
.
query
(
TBL_NAME
,
predicates
,
columns
,
(
err
,
resultSet
)
=>
{
if
(
resultSet
!==
undefined
)
{
console
.
info
(
`resultSet.rowCount:
${
resultSet
.
rowCount
}
`
);
}
if
(
callback
!==
undefined
)
{
callback
(
err
,
resultSet
);
}
});
query
(
uri
:
string
,
predicates
:
dataSharePredicates
.
DataSharePredicates
,
columns
:
Array
<
string
>
,
callback
:
Function
)
{
if
(
predicates
===
null
||
predicates
===
undefined
)
{
return
;
}
rdbStore
.
query
(
TBL_NAME
,
predicates
,
columns
,
(
err
,
resultSet
)
=>
{
if
(
resultSet
!==
undefined
)
{
console
.
info
(
`resultSet.rowCount:
${
resultSet
.
rowCount
}
`
);
}
if
(
callback
!==
undefined
)
{
callback
(
err
,
resultSet
);
}
});
}
};
```
...
...
@@ -270,14 +255,10 @@ batchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy
**示例:**
```
ts
import
r
db
from
'
@ohos.data.relationalStore
'
;
import
r
elationalStore
from
'
@ohos.data.relationalStore
'
;
import
{
ValuesBucket
}
from
'
@ohos.data.ValuesBucket
'
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
:
relationalStore
.
RdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
...
...
@@ -313,6 +294,8 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
normalizeUri
(
uri
:
string
,
callback
:
Function
)
{
let
key
=
'
code
'
;
...
...
@@ -346,6 +329,8 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
denormalizeUri
(
uri
:
string
,
callback
:
Function
)
{
let
key
=
'
code
'
;
...
...
zh-cn/application-dev/reference/apis/js-apis-data-DataShareResultSet.md
浏览文件 @
2661d914
...
...
@@ -24,27 +24,29 @@ import dataShare from '@ohos.data.dataShare';
import
dataSharePredicates
from
'
@ohos.data.dataSharePredicates
'
import
{
BusinessError
}
from
'
@ohos.base
'
let
dataShareHelper
:
dataShare
.
DataShareHelper
;
let
dataShareHelper
:
dataShare
.
DataShareHelper
|
undefined
=
undefined
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
await
dataShare
.
createDataShareHelper
(
this
.
context
,
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
error
(
"
createDataShareHelper fail, error message :
"
+
err
);
}
else
{
console
.
info
(
"
createDataShareHelper end, data :
"
+
data
);
dataShareHelper
=
data
;
}
if
(
err
!=
undefined
)
{
console
.
error
(
"
createDataShareHelper fail, error message :
"
+
err
);
}
else
{
console
.
info
(
"
createDataShareHelper end, data :
"
+
data
);
dataShareHelper
=
data
;
}
});
let
columns
=
[
"
*
"
];
let
da
=
new
dataSharePredicates
.
DataSharePredicates
();
let
resultSet
:
DataShareResultSet
;
let
resultSet
:
DataShareResultSet
|
undefined
=
undefined
;
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
dataShareHelper
.
query
(
uri
,
da
,
columns
).
then
((
data
:
DataShareResultSet
)
=>
{
if
(
dataShareHelper
!=
undefined
)
{
(
dataShareHelper
as
dataShare
.
DataShareHelper
).
query
(
uri
,
da
,
columns
).
then
((
data
:
DataShareResultSet
)
=>
{
console
.
info
(
"
query end, data :
"
+
data
);
resultSet
=
data
;
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
"
query fail, error message :
"
+
err
);
});
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
"
query fail, error message :
"
+
err
);
});
}
```
## DataShareResultSet
...
...
@@ -78,8 +80,10 @@ goToFirstRow(): boolean
**示例:**
```
ts
let
isGoTOFirstRow
=
resultSet
.
goToFirstRow
();
console
.
info
(
'
resultSet.goToFirstRow:
'
+
isGoTOFirstRow
);
if
(
resultSet
!=
undefined
)
{
let
isGoToFirstRow
=
(
resultSet
as
DataShareResultSet
).
goToFirstRow
();
console
.
info
(
'
resultSet.goToFirstRow:
'
+
isGoToFirstRow
);
}
```
### goToLastRow
...
...
@@ -99,8 +103,10 @@ goToLastRow(): boolean
**示例:**
```
ts
let
isGoToLastRow
=
resultSet
.
goToLastRow
();
console
.
info
(
'
resultSet.goToLastRow:
'
+
isGoToLastRow
);
if
(
resultSet
!=
undefined
)
{
let
isGoToLastRow
=
(
resultSet
as
DataShareResultSet
).
goToLastRow
();
console
.
info
(
'
resultSet.goToLastRow:
'
+
isGoToLastRow
);
}
```
### goToNextRow
...
...
@@ -120,8 +126,10 @@ goToNextRow(): boolean
**示例:**
```
ts
let
isGoToNextRow
=
resultSet
.
goToNextRow
();
console
.
info
(
'
resultSet.goToNextRow:
'
+
isGoToNextRow
);
if
(
resultSet
!=
undefined
)
{
let
isGoToNextRow
=
(
resultSet
as
DataShareResultSet
).
goToNextRow
();
console
.
info
(
'
resultSet.goToNextRow:
'
+
isGoToNextRow
);
}
```
### goToPreviousRow
...
...
@@ -141,8 +149,10 @@ goToPreviousRow(): boolean
**示例:**
```
ts
let
isGoToPreviousRow
=
resultSet
.
goToPreviousRow
();
console
.
info
(
'
resultSet.goToPreviousRow:
'
+
isGoToPreviousRow
);
if
(
resultSet
!=
undefined
)
{
let
isGoToPreviousRow
=
(
resultSet
as
DataShareResultSet
).
goToPreviousRow
();
console
.
info
(
'
resultSet.goToPreviousRow:
'
+
isGoToPreviousRow
);
}
```
### goTo
...
...
@@ -169,8 +179,10 @@ goTo(offset:number): boolean
```
ts
let
goToNum
=
1
;
let
isGoTo
=
resultSet
.
goTo
(
goToNum
);
console
.
info
(
'
resultSet.goTo:
'
+
isGoTo
);
if
(
resultSet
!=
undefined
)
{
let
isGoTo
=
(
resultSet
as
DataShareResultSet
).
goTo
(
goToNum
);
console
.
info
(
'
resultSet.goTo:
'
+
isGoTo
);
}
```
### goToRow
...
...
@@ -197,8 +209,10 @@ goToRow(position: number): boolean
```
ts
let
goToRowNum
=
2
;
let
isGoToRow
=
resultSet
.
goToRow
(
goToRowNum
);
console
.
info
(
'
resultSet.goToRow:
'
+
isGoToRow
);
if
(
resultSet
!=
undefined
)
{
let
isGoToRow
=
(
resultSet
as
DataShareResultSet
).
goToRow
(
goToRowNum
);
console
.
info
(
'
resultSet.goToRow:
'
+
isGoToRow
);
}
```
### getBlob
...
...
@@ -225,9 +239,11 @@ getBlob(columnIndex: number): Uint8Array
```
ts
let
columnIndex
=
1
;
let
goToFirstRow
=
resultSet
.
goToFirstRow
();
let
getBlob
=
resultSet
.
getBlob
(
columnIndex
);
console
.
info
(
'
resultSet.getBlob:
'
+
getBlob
);
if
(
resultSet
!=
undefined
)
{
let
goToFirstRow
=
(
resultSet
as
DataShareResultSet
).
goToFirstRow
();
let
getBlob
=
(
resultSet
as
DataShareResultSet
).
getBlob
(
columnIndex
);
console
.
info
(
'
resultSet.getBlob:
'
+
getBlob
);
}
```
### getString
...
...
@@ -254,9 +270,11 @@ getString(columnIndex: number): string
```
ts
let
columnIndex
=
1
;
let
goToFirstRow
=
resultSet
.
goToFirstRow
();
let
getString
=
resultSet
.
getString
(
columnIndex
);
console
.
info
(
'
resultSet.getString:
'
+
getString
);
if
(
resultSet
!=
undefined
)
{
let
goToFirstRow
=
(
resultSet
as
DataShareResultSet
).
goToFirstRow
();
let
getString
=
(
resultSet
as
DataShareResultSet
).
getString
(
columnIndex
);
console
.
info
(
'
resultSet.getString:
'
+
getString
);
}
```
### getLong
...
...
@@ -283,9 +301,11 @@ getLong(columnIndex: number): number
```
ts
let
columnIndex
=
1
;
let
goToFirstRow
=
resultSet
.
goToFirstRow
();
let
getLong
=
resultSet
.
getLong
(
columnIndex
);
console
.
info
(
'
resultSet.getLong:
'
+
getLong
);
if
(
resultSet
!=
undefined
)
{
let
goToFirstRow
=
(
resultSet
as
DataShareResultSet
).
goToFirstRow
();
let
getLong
=
(
resultSet
as
DataShareResultSet
).
getLong
(
columnIndex
);
console
.
info
(
'
resultSet.getLong:
'
+
getLong
);
}
```
### getDouble
...
...
@@ -312,9 +332,11 @@ getDouble(columnIndex: number): number
```
ts
let
columnIndex
=
1
;
let
goToFirstRow
=
resultSet
.
goToFirstRow
();
let
getDouble
=
resultSet
.
getDouble
(
columnIndex
);
console
.
info
(
'
resultSet.getDouble:
'
+
getDouble
);
if
(
resultSet
!=
undefined
)
{
let
goToFirstRow
=
(
resultSet
as
DataShareResultSet
).
goToFirstRow
();
let
getDouble
=
(
resultSet
as
DataShareResultSet
).
getDouble
(
columnIndex
);
console
.
info
(
'
resultSet.getDouble:
'
+
getDouble
);
}
```
### close
...
...
@@ -328,7 +350,9 @@ close(): void
**示例:**
```
ts
resultSet
.
close
();
if
(
resultSet
!=
undefined
)
{
(
resultSet
as
DataShareResultSet
).
close
();
}
```
### getColumnIndex
...
...
@@ -355,8 +379,10 @@ getColumnIndex(columnName: string): number
```
ts
let
ColumnName
=
"
name
"
;
let
getColumnIndex
=
resultSet
.
getColumnIndex
(
ColumnName
);
console
.
info
(
'
resultSet.getColumnIndex:
'
+
getColumnIndex
);
if
(
resultSet
!=
undefined
)
{
let
getColumnIndex
=
(
resultSet
as
DataShareResultSet
).
getColumnIndex
(
ColumnName
);
console
.
info
(
'
resultSet.getColumnIndex:
'
+
getColumnIndex
);
}
```
### getColumnName
...
...
@@ -383,8 +409,10 @@ getColumnName(columnIndex: number): string
```
ts
let
columnIndex
=
1
;
let
getColumnName
=
resultSet
.
getColumnName
(
columnIndex
);
console
.
info
(
'
resultSet.getColumnName:
'
+
getColumnName
);
if
(
resultSet
!=
undefined
)
{
let
getColumnName
=
(
resultSet
as
DataShareResultSet
).
getColumnName
(
columnIndex
);
console
.
info
(
'
resultSet.getColumnName:
'
+
getColumnName
);
}
```
### getDataType
...
...
@@ -411,8 +439,10 @@ getDataType(columnIndex: number): DataType
```
ts
let
columnIndex
=
1
;
let
getDataType
=
resultSet
.
getDataType
(
columnIndex
);
console
.
info
(
'
resultSet.getDataType:
'
+
getDataType
);
if
(
resultSet
!=
undefined
)
{
let
getDataType
=
(
resultSet
as
DataShareResultSet
).
getDataType
(
columnIndex
);
console
.
info
(
'
resultSet.getDataType:
'
+
getDataType
);
}
```
## DataType
...
...
zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md
浏览文件 @
2661d914
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录