diff --git a/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java b/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java index 93f0c63cc96..21cfcde1d84 100644 --- a/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java @@ -552,6 +552,7 @@ private void setupViewModels(FormEntryViewModelFactory formEntryViewModelFactory identityPromptViewModel.isFormEntryCancelled().observe(this, isFormEntryCancelled -> { if (isFormEntryCancelled) { + identityPromptViewModel.exit(); exit(); } }); diff --git a/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java b/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java index 34b0a61ffaa..c1cc079fc9b 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java +++ b/collect_app/src/main/java/org/odk/collect/android/formentry/audit/IdentityPromptViewModel.java @@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModel; import org.odk.collect.android.javarosawrapper.FormController; +import org.odk.collect.android.utilities.FileUtils; public class IdentityPromptViewModel extends ViewModel { @@ -20,6 +21,7 @@ public class IdentityPromptViewModel extends ViewModel { private String identity = ""; private String formName; + private String instanceFolder; public IdentityPromptViewModel() { updateRequiresIdentity(); @@ -28,6 +30,7 @@ public IdentityPromptViewModel() { public void formLoaded(@NonNull FormController formController) { this.formName = formController.getFormTitle(); this.auditEventLogger = formController.getAuditEventLogger(); + this.instanceFolder = formController.getInstanceFile().getParent(); updateRequiresIdentity(); } @@ -72,4 +75,8 @@ private static boolean userIsValid(String user) { public String getFormTitle() { return formName; } + + public void exit() { + FileUtils.purgeMediaPath(instanceFolder); + } }