Reputation: 1481
When I need to open a file with SAF (from storage or from DocumentsProvider) I just call Intent :
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(TYPE_ALL);
try {
startActivityForResult(intent, OPEN_REQUEST_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, R.string.excaption_not_found_open,
Toast.LENGTH_SHORT).show();
}
When I need to delete a FILE I do just the same, except OPEN_REQUEST_CODE - I change it with DELETE_REQUEST_CODE, get URI and call Delete() method.
The problem is I don't know how to delete DIRECTORY. I have a method that does it pragmatically, but I can't figure how to use it with standard file viewer - it only OPENS directory - there is no Intent to delete it... I guess I have to write my own File Manager to do that. Is there any other way?
Upvotes: 2
Views: 804
Reputation: 2938
Check this from the Android Developer documentation:
Upvotes: 2