Commit bd9f84f7 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

File deletion: prevent crash

Also, normal delete method for pre-Lollipop devices
parent fd411dbd
......@@ -210,10 +210,13 @@ public class FileUtils {
return ret;
public static boolean deleteFile (Uri uri){
if (uri.getPath().startsWith(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)) return deleteFile(uri.getPath());
public static boolean deleteFile (Uri uri) {
if (!AndroidUtil.isLolliPopOrLater || uri.getPath().startsWith(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)) return deleteFile(uri.getPath());
final DocumentFile docFile = FileUtils.findFile(uri);
return docFile != null && docFile.delete();
if (docFile != null) try {
return docFile.delete();
} catch (Exception ignored) {}
return false;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment