未验证 提交 7c2ddfa8 编写于 作者: O openharmony_ci 提交者: Gitee

!23792 [翻译完成】#I7W3UW (仅涉及代码修改)

Merge pull request !23792 from Annie_wang/PR22990
...@@ -43,11 +43,11 @@ FA model: ...@@ -43,11 +43,11 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call getRdbStore. // Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db"} 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) { if (err) {
console.info("Failed to get RdbStore, err: " + err) console.info("Failed to get RdbStore, err: " + err)
return return
...@@ -61,23 +61,26 @@ Stage model: ...@@ -61,23 +61,26 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; 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 { interface storeConfig {
onWindowStageCreate(windowStage){ name: string
context = this.context
}
} }
// Call getRdbStore. class EntryAbility extends UIAbility {
const STORE_CONFIG = { name: "RdbTest.db"} onWindowStageCreate(windowStage: window.WindowStage){
data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { let STORE_CONFIG: storeConfig = { name: "RdbTest.db"};
if (err) { data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, (err: BusinessError, rdbStore: data_rdb.RdbStore) => {
if (err) {
console.info("Failed to get RdbStore, err: " + err) console.info("Failed to get RdbStore, err: " + err)
return return
} }
console.log("Got RdbStore successfully.") console.log("Got RdbStore successfully.")
}) })
}
}
``` ```
## data_rdb.getRdbStore ## data_rdb.getRdbStore
...@@ -109,7 +112,7 @@ FA model: ...@@ -109,7 +112,7 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call getRdbStore. // Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db" } const STORE_CONFIG = { name: "RdbTest.db" }
...@@ -126,21 +129,26 @@ Stage model: ...@@ -126,21 +129,26 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; 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 { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage: window.WindowStage){
context = this.context context = this.context
} }
} }
// Call getRdbStore. // Call getRdbStore.
const STORE_CONFIG = { name: "RdbTest.db" } let STORE_CONFIG: storeConfig = { name: "RdbTest.db"};
let promise = data_rdb.getRdbStore(context, STORE_CONFIG, 1); let promise = data_rdb.getRdbStore(context, STORE_CONFIG, 1);
promise.then(async (rdbStore) => { promise.then(async (rdbStore: data_rdb.RdbStore) => {
console.log("Got RdbStore successfully.") console.log("Got RdbStore successfully.")
}).catch((err) => { }).catch((err: BusinessError) => {
console.log("Failed to get RdbStore, err: " + err) console.log("Failed to get RdbStore, err: " + err)
}) })
``` ```
...@@ -167,15 +175,15 @@ FA model: ...@@ -167,15 +175,15 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call deleteRdbStore. // Call deleteRdbStore.
data_rdb.deleteRdbStore(context, "RdbTest.db", function (err) { data_rdb.deleteRdbStore(context, "RdbTest.db", (err) => {
if (err) { if (err) {
console.info("Failed to delete RdbStore, err: " + err) console.info("Failed to delete RdbStore, err: " + err)
return return
} }
console.log("Deleted RdbStore successfully.") console.log("Deleted RdbStore successfully.")
}) })
``` ```
...@@ -184,21 +192,22 @@ Stage model: ...@@ -184,21 +192,22 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
let context; let context: Context;
class EntryAbility extends UIAbility { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage: window.WindowStage){
context = this.context context = this.context
} }
} }
// Call deleteRdbStore. // Call deleteRdbStore.
data_rdb.deleteRdbStore(context, "RdbTest.db", function (err) { data_rdb.deleteRdbStore(context, "RdbTest.db", (err) => {
if (err) { if (err) {
console.info("Failed to delete RdbStore, err: " + err) console.info("Failed to delete RdbStore, err: " + err)
return return
} }
console.log("Deleted RdbStore successfully.") console.log("Deleted RdbStore successfully.")
}) })
``` ```
...@@ -230,7 +239,7 @@ FA model: ...@@ -230,7 +239,7 @@ FA model:
```js ```js
// Obtain the context. // Obtain the context.
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
let context = featureAbility.getContext() let context: Context;
// Call deleteRdbStore. // Call deleteRdbStore.
let promise = data_rdb.deleteRdbStore(context, "RdbTest.db") let promise = data_rdb.deleteRdbStore(context, "RdbTest.db")
...@@ -246,20 +255,22 @@ Stage model: ...@@ -246,20 +255,22 @@ Stage model:
```ts ```ts
// Obtain the context. // Obtain the context.
import UIAbility from '@ohos.app.ability.UIAbility'; 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 { class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage){ onWindowStageCreate(windowStage: window.WindowStage){
context = this.context context = this.context
} }
} }
// Call deleteRdbStore. // Call deleteRdbStore.
let promise = data_rdb.deleteRdbStore(context, "RdbTest.db") let promise = data_rdb.deleteRdbStore(context, "RdbTest.db")
promise.then(()=>{ promise.then(()=>{
console.log("Deleted RdbStore successfully.") console.log("Deleted RdbStore successfully.")
}).catch((err) => { }).catch((err: BusinessError) => {
console.info("Failed to delete RdbStore, err: " + err) 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 ...@@ -371,8 +382,8 @@ Sets an **RdbPredicates** to specify the remote devices to connect on the networ
```js ```js
import deviceManager from '@ohos.distributedHardware.deviceManager'; import deviceManager from '@ohos.distributedHardware.deviceManager';
let dmInstance = null; let dmInstance: deviceManager.DeviceManager = null;
let deviceIds = []; let deviceIds: Array<string> = [];
deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => { deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) => {
if (err) { if (err) {
...@@ -381,7 +392,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) ...@@ -381,7 +392,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager)
} }
dmInstance = manager; dmInstance = manager;
let devices = dmInstance.getTrustedDeviceListSync(); 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; deviceIds[i] = devices[i].deviceId;
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册