From: Damyan Ivanov Date: Fri, 19 Feb 2021 16:23:38 +0000 (+0000) Subject: initialize Room after all legacy upgrading is done X-Git-Tag: v0.17.0~76 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=3e01d1b42b99c9fce426df1750c0fae5a8fd0f0a;p=mobile-ledger.git initialize Room after all legacy upgrading is done this is here until all database tables are described in Room and the structure changes can be migrated too Room too. --- diff --git a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java index ac78e231..78c325e1 100644 --- a/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java +++ b/app/src/main/java/net/ktnx/mobileledger/utils/MobileLedgerDatabase.java @@ -26,6 +26,7 @@ import android.database.sqlite.SQLiteOpenHelper; import androidx.lifecycle.MutableLiveData; import net.ktnx.mobileledger.BuildConfig; +import net.ktnx.mobileledger.db.DB; import java.io.BufferedReader; import java.io.IOException; @@ -43,7 +44,14 @@ public class MobileLedgerDatabase extends SQLiteOpenHelper { private static final int LATEST_REVISION = 58; private static final String CREATE_DB_SQL = "create_db"; private final Application mContext; - + @Override + public void onOpen(SQLiteDatabase db) { + super.onOpen(db); + // force a check by Room to ensure everything is OK + // TODO: remove when all DB structure manipulation is via Room + DB.get() + .compileStatement("SELECT COUNT(*) FROM profiles"); + } public MobileLedgerDatabase(Application context) { super(context, DB_NAME, null, LATEST_REVISION); debug("db", "creating helper instance");