diff --git a/zh-cn/application-dev/application-models/create-dataability.md b/zh-cn/application-dev/application-models/create-dataability.md index 6b204464744ccd16cd4d059dac7e4af6f2b51dd5..02b5bdf84b8eddea32d27e30590f1facfd63a0a8 100644 --- a/zh-cn/application-dev/application-models/create-dataability.md +++ b/zh-cn/application-dev/application-models/create-dataability.md @@ -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 diff --git a/zh-cn/application-dev/application-models/js-ui-widget-development.md b/zh-cn/application-dev/application-models/js-ui-widget-development.md index ce3d502f6539821846625f23cac749d9c362e456..7ef75f5fb7aeb381dea35b14255d704ebc13863d 100644 --- a/zh-cn/application-dev/application-models/js-ui-widget-development.md +++ b/zh-cn/application-dev/application-models/js-ui-widget-development.md @@ -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}`); diff --git a/zh-cn/application-dev/application-models/widget-development-fa.md b/zh-cn/application-dev/application-models/widget-development-fa.md index f31c37dcf514dd958a0b5ec46b6fe45730503c62..1f560396e057c6e4a0e5be36faced92cd0af49b8 100644 --- a/zh-cn/application-dev/application-models/widget-development-fa.md +++ b/zh-cn/application-dev/application-models/widget-development-fa.md @@ -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}`);