中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
Stage模型下如何删除数据库文件?
微信扫码分享
import { ValuesBucket } from '@ohos.data.ValuesBucket'; import { relationalStore } from '@kit.ArkData'; import { BusinessError } from '@kit.BasicServicesKit'; let store: relationalStore.RdbStore | undefined = undefined; @Entry @Component struct Index { build() { Column() { Button("删除数据库").onClick(() => { //获取store步骤省略 if (store !== undefined) { relationalStore.deleteRdbStore(getContext(), 'RdbTest.db', (err: BusinessError) => { if (err) { console.error(`Failed to delete RdbStore. Code:${err.code}, message:${err.message}`); return; } console.info('Succeeded in deleting RdbStore.'); }); } }) } .width('100%') .height('100%') .justifyContent(FlexAlign.Center) } }