From d86f0787da9177a88b5db84d8367b9f97ad35821 Mon Sep 17 00:00:00 2001 From: ChaosKid42 Date: Thu, 7 Jun 2018 08:09:31 +0200 Subject: [PATCH] fix cleanPrivateStorage() (#3065) --- .../conversations/ui/SettingsActivity.java | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java index fdd7adc49..653a55032 100644 --- a/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/SettingsActivity.java @@ -278,34 +278,15 @@ public class SettingsActivity extends XmppActivity implements } private boolean cleanPrivateStorage() { - cleanPrivatePictures(); - cleanPrivateFiles(); + for(String type : Arrays.asList("Images", "Videos", "Files", "Recordings")) { + cleanPrivateFiles(type); + } return true; } - private void cleanPrivatePictures() { + private void cleanPrivateFiles(final String type) { try { - File dir = new File(getFilesDir().getAbsolutePath(), "/Pictures/"); - File[] array = dir.listFiles(); - if (array != null) { - for (int b = 0; b < array.length; b++) { - String name = array[b].getName().toLowerCase(); - if (name.equals(".nomedia")) { - continue; - } - if (array[b].isFile()) { - array[b].delete(); - } - } - } - } catch (Throwable e) { - Log.e("CleanCache", e.toString()); - } - } - - private void cleanPrivateFiles() { - try { - File dir = new File(getFilesDir().getAbsolutePath(), "/Files/"); + File dir = new File(getFilesDir().getAbsolutePath(), "/" + type + "/"); File[] array = dir.listFiles(); if (array != null) { for (int b = 0; b < array.length; b++) {