#鸿蒙学习大百科#Stage模型下如何删除数据库文件?

Stage模型下如何删除数据库文件?

HarmonyOS
2024-10-23 11:39:44
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
花鸟吹雪
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)
  }
}
分享
微博
QQ
微信
回复
2024-10-23 17:25:36
相关问题