提交 c138e09b 编写于 作者: Y yuyaozhi

Fix vod error

Signed-off-by: Nyuyaozhi <yuyaozhi@huawei.com>
上级 5a4ce19a
......@@ -9,18 +9,18 @@
```ts
import featureAbility from '@ohos.ability.featureAbility'
import dataAbility from '@ohos.data.dataAbility'
import dataRdb from '@ohos.data.rdb'
import relationalStore from '@ohos.data.relationalStore'
const TABLE_NAME = 'book'
const STORE_CONFIG = { name: 'book.db' }
const SQL_CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS book(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, introduction TEXT NOT NULL)'
let rdbStore: dataRdb.RdbStore = undefined
let rdbStore: relationalStore.RdbStore = undefined
export default {
onInitialized(abilityInfo) {
console.info('DataAbility onInitialized, abilityInfo:' + abilityInfo.bundleName)
let context = featureAbility.getContext()
dataRdb.getRdbStore(context, STORE_CONFIG, 1, (err, store) => {
relationalStore.getRdbStore(context, STORE_CONFIG, (err, store) => {
console.info('DataAbility getRdbStore callback')
store.executeSql(SQL_CREATE_TABLE, [])
rdbStore = store
......
......@@ -102,7 +102,7 @@ Stage卡片开发,即基于[Stage模型](stage-model-development-overview.md)
import formBindingData from '@ohos.app.form.formBindingData';
import formInfo from '@ohos.app.form.formInfo';
import formProvider from '@ohos.app.form.formProvider';
import dataStorage from '@ohos.data.storage';
import dataPreferences from '@ohos.data.preferences';
```
2. 在EntryFormAbility.ts中,实现FormExtension生命周期接口。
......@@ -255,7 +255,7 @@ async function storeFormInfo(formId: string, formName: string, tempFlag: boolean
"updateCount": 0
};
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
const storage = await dataPreferences.getPreferences(this.context, DATA_STORAGE_PATH);
// put form info
await storage.put(formId, JSON.stringify(formInfo));
console.info(`[EntryFormAbility] storeFormInfo, put form info successfully, formId: ${formId}`);
......@@ -294,7 +294,7 @@ export default class EntryFormAbility extends FormExtension {
const DATA_STORAGE_PATH = "/data/storage/el2/base/haps/form_store";
async function deleteFormInfo(formId: string) {
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
const storage = await dataPreferences.getPreferences(this.context, DATA_STORAGE_PATH);
// del form info
await storage.delete(formId);
console.info(`[EntryFormAbility] deleteFormInfo, del form info successfully, formId: ${formId}`);
......
......@@ -114,7 +114,7 @@ FA卡片开发,即基于[FA模型](fa-model-development-overview.md)的卡片
import formBindingData from '@ohos.app.form.formBindingData';
import formInfo from '@ohos.app.form.formInfo';
import formProvider from '@ohos.app.form.formProvider';
import dataStorage from '@ohos.data.storage';
import dataPreferences from '@ohos.data.preferences';
```
2. 在form.ts中,实现卡片生命周期接口
......@@ -263,7 +263,7 @@ async function storeFormInfo(formId: string, formName: string, tempFlag: boolean
"updateCount": 0
};
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
const storage = await dataPreferences.getPreferences(this.context, DATA_STORAGE_PATH);
// put form info
await storage.put(formId, JSON.stringify(formInfo));
console.info(`storeFormInfo, put form info successfully, formId: ${formId}`);
......@@ -301,7 +301,7 @@ async function storeFormInfo(formId: string, formName: string, tempFlag: boolean
const DATA_STORAGE_PATH = "/data/storage/el2/base/haps/form_store";
async function deleteFormInfo(formId: string) {
try {
const storage = await dataStorage.getStorage(DATA_STORAGE_PATH);
const storage = await dataPreferences.getPreferences(this.context, DATA_STORAGE_PATH);
// del form info
await storage.delete(formId);
console.info(`deleteFormInfo, del form info successfully, formId: ${formId}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册