return result;
}
+ public void wipeAllData() {
+ SQLiteDatabase db = MLDB.getDatabase();
+ db.beginTransaction();
+ try {
+ String[] pUuid = new String[]{uuid};
+ db.execSQL("delete from options where profile=?", pUuid);
+ db.execSQL("delete from accounts where profile=?", pUuid);
+ db.execSQL("delete from account_values where profile=?", pUuid);
+ db.execSQL("delete from transactions where profile=?", pUuid);
+ db.execSQL("delete from transaction_accounts where profile=?", pUuid);
+ db.setTransactionSuccessful();
+ }
+ finally {
+ db.endTransaction();
+ }
+ }
}
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.textfield.TextInputLayout;
+import net.ktnx.mobileledger.BuildConfig;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
return false;
});
menuDeleteProfile.setVisible((mProfile != null) && (Data.profiles.size() > 1));
+
+ if (BuildConfig.DEBUG) {
+ final MenuItem menuWipeProfileData = menu.findItem(R.id.menuWipeData);
+ menuWipeProfileData.setOnMenuItemClickListener(this::onWipeDataMenuClicked);
+ menuWipeProfileData.setVisible(mProfile != null);
+ }
+ }
+ private boolean onWipeDataMenuClicked(MenuItem item) {
+ // this is a development option, so no confirmation
+ mProfile.wipeAllData();
+ Data.profile.forceNotifyObservers();
+ return true;
}
@Override
public void onCreate(Bundle savedInstanceState) {
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright © 2019 Damyan Ivanov.
~ This file is part of MoLe.
~ MoLe is free software: you can distribute it and/or modify it
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/menuDelete"
android:title="@string/delete_profile"
android:titleCondensed="@string/delete"
app:showAsAction="ifRoom" />
+ <item
+ android:id="@+id/menuWipeData"
+ android:title="Wipe profile data"
+ android:titleCondensed="Wipe"
+ app:showAsAction="never"
+ android:visible="false"
+ tools:ignore="HardcodedText" />
</menu>
\ No newline at end of file