]> git.ktnx.net Git - mobile-ledger.git/commitdiff
remove all profile data when removing a profile
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 18 Mar 2019 09:26:49 +0000 (11:26 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 25 Mar 2019 06:17:36 +0000 (06:17 +0000)
app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java

index 17b6ac7ae9b8128007c95fefd93a17ab0f978a42..71b53cd760119cf323a93c0503378c8ae3d955e7 100644 (file)
@@ -282,8 +282,19 @@ public final class MobileLedgerProfile {
     }
     public void removeFromDB() {
         SQLiteDatabase db = MLDB.getWritableDatabase();
-        Log.d("db", String.format("removing progile %s from DB", uuid));
-        db.execSQL("delete from profiles where uuid=?", new Object[]{uuid});
+        Log.d("db", String.format("removing profile %s from DB", uuid));
+        try {
+            db.beginTransaction();
+            db.execSQL("delete from profiles where uuid=?", new Object[]{uuid});
+            db.execSQL("delete from accounts where profile=?", new Object[]{uuid});
+            db.execSQL("delete from account_values where profile=?", new Object[]{uuid});
+            db.execSQL("delete from transactions where profile=?", new Object[]{uuid});
+            db.execSQL("delete from transaction_accounts where profile=?", new Object[]{uuid});
+            db.setTransactionSuccessful();
+        }
+        finally {
+            db.endTransaction();
+        }
     }
     @NonNull
     public LedgerAccount loadAccount(String name) {