From 1fb3cc1beb06f54fc215c8947ac961b50fb05966 Mon Sep 17 00:00:00 2001 From: zhangchunyan22 Date: Thu, 28 Jul 2022 11:28:03 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BAdb?= =?UTF-8?q?=E8=B7=AF=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/phone/src/main/ets/pages/MyNoteHome.ets | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/product/phone/src/main/ets/pages/MyNoteHome.ets b/product/phone/src/main/ets/pages/MyNoteHome.ets index 632ae8c..5989b0a 100644 --- a/product/phone/src/main/ets/pages/MyNoteHome.ets +++ b/product/phone/src/main/ets/pages/MyNoteHome.ets @@ -67,14 +67,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) + } } } -- Gitee From 25faf448a6aed06d500ace3b22601777e46cb94f Mon Sep 17 00:00:00 2001 From: zhangchunyan22 Date: Fri, 29 Jul 2022 10:50:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BAdb?= =?UTF-8?q?=E8=B7=AF=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) + } } } -- Gitee