From 8c92dd30f3703556f7edda057e997283311be873 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 15 Apr 2021 18:46:05 +0000 Subject: [PATCH] Room-based profile wipe used only in debug builds as before --- .../net/ktnx/mobileledger/db/Profile.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/db/Profile.java b/app/src/main/java/net/ktnx/mobileledger/db/Profile.java index 06728c02..76d0e059 100644 --- a/app/src/main/java/net/ktnx/mobileledger/db/Profile.java +++ b/app/src/main/java/net/ktnx/mobileledger/db/Profile.java @@ -17,10 +17,19 @@ package net.ktnx.mobileledger.db; +import android.os.AsyncTask; + import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.room.ColumnInfo; import androidx.room.Entity; import androidx.room.PrimaryKey; +import androidx.room.Transaction; + +import net.ktnx.mobileledger.dao.AccountDAO; +import net.ktnx.mobileledger.dao.DescriptionHistoryDAO; +import net.ktnx.mobileledger.dao.OptionDAO; +import net.ktnx.mobileledger.dao.TransactionDAO; @Entity(tableName = "profiles") public class Profile { @@ -186,4 +195,26 @@ public class Profile { public String toString() { return getName(); } + @Transaction + public void wipeAllDataSync() { + OptionDAO optDao = DB.get() + .getOptionDAO(); + optDao.deleteSync(optDao.allForProfileSync(id)); + + AccountDAO accDao = DB.get() + .getAccountDAO(); + accDao.deleteSync(accDao.allForProfileSync(id)); + + TransactionDAO trnDao = DB.get() + .getTransactionDAO(); + trnDao.deleteSync(trnDao.allForProfileSync(id)); + + DescriptionHistoryDAO descDao = DB.get() + .getDescriptionHistoryDAO(); + descDao.sweepSync(); + } + public void wipeAllData() { + AsyncTask.execute(this::wipeAllDataSync); + } + } -- 2.39.5