mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 12:40:24 +00:00
Clear cache on update
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -30,4 +31,27 @@ public class FileUtils {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDirectoryContents(File directory) throws IOException {
|
||||
if (directory == null || !directory.exists() || !directory.isDirectory()) return;
|
||||
|
||||
File[] files = directory.listFiles();
|
||||
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) deleteDirectory(file);
|
||||
else file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDirectory(File directory) throws IOException {
|
||||
if (directory == null || !directory.exists() || !directory.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
deleteDirectoryContents(directory);
|
||||
|
||||
directory.delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user