X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FApp.java;h=2fc6d65c276dafd0b41131791317f7f3238af843;hb=f973784f579d42988174acf0b24593aa23180fa6;hp=7935beba307d7ffe4ff1eef8dcbef45a38535e2d;hpb=dfb7d2672b202a4ca2745b5630ef21f8ef3f0bdd;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/App.java b/app/src/main/java/net/ktnx/mobileledger/App.java index 7935beba..2fc6d65c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/App.java +++ b/app/src/main/java/net/ktnx/mobileledger/App.java @@ -1,5 +1,5 @@ /* - * Copyright © 2020 Damyan Ivanov. + * Copyright © 2021 Damyan Ivanov. * This file is part of MoLe. * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -23,8 +23,6 @@ import android.content.res.Resources; import android.database.sqlite.SQLiteDatabase; import android.util.Log; -import androidx.room.Room; - import net.ktnx.mobileledger.db.DB; import net.ktnx.mobileledger.model.Data; import net.ktnx.mobileledger.ui.profiles.ProfileDetailModel; @@ -45,22 +43,12 @@ public class App extends Application { private static ProfileDetailModel profileModel; private MobileLedgerDatabase dbHelper; private boolean monthNamesPrepared = false; - private DB roomDatabase; public static SQLiteDatabase getDatabase() { if (instance == null) throw new RuntimeException("Application not created yet"); return instance.getDB(); } - public static DB getRoomDB() { - if (instance == null) - throw new RuntimeException("Application not created yet"); - - return instance.getRoomDatabase(); - } - public DB getRoomDatabase(){ - return roomDatabase; - } public static void prepareMonthNames() { instance.prepareMonthNames(false); } @@ -99,8 +87,6 @@ public class App extends Application { Logger.debug("flow", "App onCreate()"); instance = this; super.onCreate(); - roomDatabase = Room.databaseBuilder(this, DB.class, MobileLedgerDatabase.DB_NAME) - .build(); Data.refreshCurrencyData(Locale.getDefault()); Authenticator.setDefault(new Authenticator() { @Override @@ -158,6 +144,10 @@ public class App extends Application { if (dbHelper != null) return; + // Let Room do any possible migrations + // this method may be removed when all DB access is made via Room + DB.get() + .compileStatement("select count(*) from profiles"); dbHelper = new MobileLedgerDatabase(this); } }