Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7c2ddfa8
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7c2ddfa8
编写于
9月 05, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 05, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23792 [翻译完成】#I7W3UW (仅涉及代码修改)
Merge pull request !23792 from Annie_wang/PR22990
上级
714ccdef
68739026
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
52 deletion
+63
-52
en/application-dev/reference/apis/js-apis-data-rdb.md
en/application-dev/reference/apis/js-apis-data-rdb.md
+63
-52
未找到文件。
en/application-dev/reference/apis/js-apis-data-rdb.md
浏览文件 @
7c2ddfa8
...
...
@@ -43,11 +43,11 @@ FA model:
```
js
// Obtain the context.
import
featureAbility
from
'
@ohos.ability.featureAbility
'
let
context
=
featureAbility
.
getContext
()
let
context
:
Context
;
// Call getRdbStore.
const
STORE_CONFIG
=
{
name
:
"
RdbTest.db
"
}
data_rdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
function
(
err
,
rdbStore
)
{
data_rdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
(
err
,
rdbStore
)
=>
{
if
(
err
)
{
console
.
info
(
"
Failed to get RdbStore, err:
"
+
err
)
return
...
...
@@ -61,23 +61,26 @@ Stage model:
```
ts
// Obtain the context.
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
import
window
from
'
@ohos.window
'
;
let
context
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
context
=
this
.
context
}
let
context
:
Context
;
interface
storeConfig
{
name
:
string
}
// Call getRdbStore.
const
STORE_CONFIG
=
{
name
:
"
RdbTest.db
"
}
data_rdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
,
function
(
err
,
rdbStore
)
{
if
(
err
)
{
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
:
window
.
WindowStage
){
let
STORE_CONFIG
:
storeConfig
=
{
name
:
"
RdbTest.db
"
};
data_rdb
.
getRdbStore
(
this
.
context
,
STORE_CONFIG
,
1
,
(
err
:
BusinessError
,
rdbStore
:
data_rdb
.
RdbStore
)
=>
{
if
(
err
)
{
console
.
info
(
"
Failed to get RdbStore, err:
"
+
err
)
return
}
console
.
log
(
"
Got RdbStore successfully.
"
)
})
}
console
.
log
(
"
Got RdbStore successfully.
"
)
})
}
}
```
## data_rdb.getRdbStore
...
...
@@ -109,7 +112,7 @@ FA model:
```
js
// Obtain the context.
import
featureAbility
from
'
@ohos.ability.featureAbility
'
let
context
=
featureAbility
.
getContext
()
let
context
:
Context
;
// Call getRdbStore.
const
STORE_CONFIG
=
{
name
:
"
RdbTest.db
"
}
...
...
@@ -126,21 +129,26 @@ Stage model:
```
ts
// Obtain the context.
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
import
window
from
'
@ohos.window
'
;
let
context
;
let
context
:
Context
;
interface
storeConfig
{
name
:
string
}
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
w
indowStage
){
context
=
this
.
context
}
onWindowStageCreate
(
windowStage
:
window
.
W
indowStage
){
context
=
this
.
context
}
}
// Call getRdbStore.
const
STORE_CONFIG
=
{
name
:
"
RdbTest.db
"
}
let
STORE_CONFIG
:
storeConfig
=
{
name
:
"
RdbTest.db
"
};
let
promise
=
data_rdb
.
getRdbStore
(
context
,
STORE_CONFIG
,
1
);
promise
.
then
(
async
(
rdbStore
)
=>
{
console
.
log
(
"
Got RdbStore successfully.
"
)
}).
catch
((
err
)
=>
{
console
.
log
(
"
Failed to get RdbStore, err:
"
+
err
)
promise
.
then
(
async
(
rdbStore
:
data_rdb
.
RdbStore
)
=>
{
console
.
log
(
"
Got RdbStore successfully.
"
)
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
log
(
"
Failed to get RdbStore, err:
"
+
err
)
})
```
...
...
@@ -167,15 +175,15 @@ FA model:
```
js
// Obtain the context.
import
featureAbility
from
'
@ohos.ability.featureAbility
'
let
context
=
featureAbility
.
getContext
()
let
context
:
Context
;
// Call deleteRdbStore.
data_rdb
.
deleteRdbStore
(
context
,
"
RdbTest.db
"
,
function
(
err
)
{
if
(
err
)
{
console
.
info
(
"
Failed to delete RdbStore, err:
"
+
err
)
return
}
console
.
log
(
"
Deleted RdbStore successfully.
"
)
data_rdb
.
deleteRdbStore
(
context
,
"
RdbTest.db
"
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
Failed to delete RdbStore, err:
"
+
err
)
return
}
console
.
log
(
"
Deleted RdbStore successfully.
"
)
})
```
...
...
@@ -184,21 +192,22 @@ Stage model:
```
ts
// Obtain the context.
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
window
from
'
@ohos.window
'
;
let
context
;
let
context
:
Context
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
w
indowStage
){
context
=
this
.
context
}
onWindowStageCreate
(
windowStage
:
window
.
W
indowStage
){
context
=
this
.
context
}
}
// Call deleteRdbStore.
data_rdb
.
deleteRdbStore
(
context
,
"
RdbTest.db
"
,
function
(
err
)
{
if
(
err
)
{
console
.
info
(
"
Failed to delete RdbStore, err:
"
+
err
)
return
}
console
.
log
(
"
Deleted RdbStore successfully.
"
)
data_rdb
.
deleteRdbStore
(
context
,
"
RdbTest.db
"
,
(
err
)
=>
{
if
(
err
)
{
console
.
info
(
"
Failed to delete RdbStore, err:
"
+
err
)
return
}
console
.
log
(
"
Deleted RdbStore successfully.
"
)
})
```
...
...
@@ -230,7 +239,7 @@ FA model:
```
js
// Obtain the context.
import
featureAbility
from
'
@ohos.ability.featureAbility
'
let
context
=
featureAbility
.
getContext
()
let
context
:
Context
;
// Call deleteRdbStore.
let
promise
=
data_rdb
.
deleteRdbStore
(
context
,
"
RdbTest.db
"
)
...
...
@@ -246,20 +255,22 @@ Stage model:
```
ts
// Obtain the context.
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
{
BusinessError
}
from
"
@ohos.base
"
;
import
window
from
'
@ohos.window
'
;
let
context
;
let
context
:
Context
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
w
indowStage
){
context
=
this
.
context
}
onWindowStageCreate
(
windowStage
:
window
.
W
indowStage
){
context
=
this
.
context
}
}
// Call deleteRdbStore.
let
promise
=
data_rdb
.
deleteRdbStore
(
context
,
"
RdbTest.db
"
)
promise
.
then
(()
=>
{
console
.
log
(
"
Deleted RdbStore successfully.
"
)
}).
catch
((
err
)
=>
{
console
.
info
(
"
Failed to delete RdbStore, err:
"
+
err
)
console
.
log
(
"
Deleted RdbStore successfully.
"
)
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
info
(
"
Failed to delete RdbStore, err:
"
+
err
)
})
```
...
...
@@ -371,8 +382,8 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ
```
js
import
deviceManager
from
'
@ohos.distributedHardware.deviceManager
'
;
let
dmInstance
=
null
;
let
deviceIds
=
[];
let
dmInstance
:
deviceManager
.
DeviceManager
=
null
;
let
deviceIds
:
Array
<
string
>
=
[];
deviceManager
.
createDeviceManager
(
"
com.example.appdatamgrverify
"
,
(
err
,
manager
)
=>
{
if
(
err
)
{
...
...
@@ -381,7 +392,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
}
dmInstance
=
manager
;
let
devices
=
dmInstance
.
getTrustedDeviceListSync
();
for
(
var
i
=
0
;
i
<
devices
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
devices
.
length
;
i
++
)
{
deviceIds
[
i
]
=
devices
[
i
].
deviceId
;
}
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录