From 8bf1398928de82d8044684a831ddd8910ccaa33e Mon Sep 17 00:00:00 2001 From: zhangchunyan22 Date: Fri, 29 Jul 2022 10:50:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BAdb=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangchunyan22 --- product/tablet/src/main/ets/pages/MyNoteHome.ets | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/product/tablet/src/main/ets/pages/MyNoteHome.ets b/product/tablet/src/main/ets/pages/MyNoteHome.ets index fdaeaf8..bcf37dd 100644 --- a/product/tablet/src/main/ets/pages/MyNoteHome.ets +++ b/product/tablet/src/main/ets/pages/MyNoteHome.ets @@ -68,14 +68,26 @@ export struct MyNoteHomeComp { LogUtil.warn(this.TAG, 'failed to requestPermissionsFromUser : ' + err.code); }) + let dbExist = false; let dbPath = context.databaseDir + "/db/note.db" try { fileio.accessSync(dbPath) LogUtil.info(this.TAG, "db has created") RdbStoreUtil.initAppStorage(this.context) + dbExist = true } catch (err) { - LogUtil.info(this.TAG, "db has not created, start to create db") - RdbStoreUtil.createRdbStore(this.context) + LogUtil.info(this.TAG, "db has not created, find to rdb folder") + } + if (!dbExist) { + dbPath = context.databaseDir + "/rdb/note.db" + try{ + fileio.accessSync(dbPath) + LogUtil.info(this.TAG,"db has created") + RdbStoreUtil.initAppStorage(this.context) + } catch (err) { + LogUtil.info(this.TAG,"db has not created, start to create db") + RdbStoreUtil.createRdbStore(this.context) + } } }