fix delete file securely method and use for delete original file

This commit is contained in:
Vincent Breitmoser
2015-11-15 05:41:14 +01:00
parent bb79b44e7f
commit c4599798f9
3 changed files with 58 additions and 70 deletions

View File

@@ -800,33 +800,18 @@ public class DecryptListFragment
// we can only ever delete a file once, if we got this far either it's gone or it will never work
mCanDelete = false;
if ("file".equals(uri.getScheme())) {
File file = new File(uri.getPath());
if (file.delete()) {
try {
int deleted = FileHelper.deleteFileSecurely(activity, uri);
if (deleted > 0) {
Notify.create(activity, R.string.file_delete_ok, Style.OK).show();
} else {
Notify.create(activity, R.string.file_delete_none, Style.WARN).show();
}
return;
} catch (Exception e) {
Log.e(Constants.TAG, "exception deleting file", e);
Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show();
}
if ("content".equals(uri.getScheme())) {
try {
int deleted = activity.getContentResolver().delete(uri, null, null);
if (deleted > 0) {
Notify.create(activity, R.string.file_delete_ok, Style.OK).show();
} else {
Notify.create(activity, R.string.file_delete_none, Style.WARN).show();
}
} catch (Exception e) {
Log.e(Constants.TAG, "exception deleting file", e);
Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show();
}
return;
}
Notify.create(activity, R.string.file_delete_exception, Style.ERROR).show();
}
public class DecryptFilesAdapter extends RecyclerView.Adapter<ViewHolder> {