From 8dbd381adb4a5d4d136ab7b28407cc9b2ac4453a Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Sat, 13 Jan 2018 00:24:41 +0100 Subject: [PATCH] Fix crash with getting db Signed-off-by: Mario Danic --- .../com/nextcloud/talk/activities/MainActivity.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java index 3eab756e4..1892fa8fe 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.java @@ -96,8 +96,15 @@ public final class MainActivity extends AppCompatActivity implements ActionBarPr router = Conductor.attachRouter(this, container, savedInstanceState); - if (!router.hasRootController() && sqlCipherDatabaseSource.getWritableDatabase() != null && - userUtils.anyUserExists()) { + boolean hasDb = true; + + try { + sqlCipherDatabaseSource.getWritableDatabase(); + } catch (Exception exception) { + hasDb = false; + } + + if (!router.hasRootController() && hasDb && userUtils.anyUserExists()) { router.setRoot(RouterTransaction.with(new MagicBottomNavigationController()) .pushChangeHandler(new HorizontalChangeHandler()) .popChangeHandler(new HorizontalChangeHandler()));