Securily delete files

This commit is contained in:
M66B
2023-11-16 11:10:34 +01:00
parent 7eb345cdd6
commit 6bdab773bb
14 changed files with 53 additions and 46 deletions

View File

@@ -151,6 +151,8 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
@@ -2834,6 +2836,16 @@ public class Helper {
return files;
}
static void secureDelete(File file) {
if (file.exists()) {
try {
Files.delete(Paths.get(file.getAbsolutePath()));
} catch (IOException ex) {
Log.e(ex);
}
}
}
static long getAvailableStorageSpace() {
StatFs stats = new StatFs(Environment.getDataDirectory().getAbsolutePath());
return stats.getAvailableBlocksLong() * stats.getBlockSizeLong();