How to use the new lollipop SD Card Access API to delete and modify files
The link you mentioned (How to use the new SD-Card access API presented for Lollipop) gives instructions on how to prompt user to choose the root directory using ACTION_OPEN_DOCUMENT_TREE
.
After the user chooses the root node then your code will have a DocumentFile that represents the root node. You say you already have the file path. If so then use the segments of the file path and follow the path down the hierarchy using DocumentFile.html#listFiles().
You'll finally have the DocumentFile that represent the file you want to delete, then call DocumentFile.html#delete()
Saving files to SD card on Android Lollipop
It's impossible. User should choose directory using android's file picker. The only way to get access to folder is using:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, 42);
Because file is provided by Storage Access Framework DocumentsProvider. Actually it could return some Uri from 3-rd party app, which is not real file, but some entity, which 3-rd party app present as file.
Related Topics
How to Retrieve Data from Firebase to My Adapter
Update Data in Listfragment as Part of Viewpager
Android: Alternate Layout Xml For Landscape Mode
How to Exit from the Application and Show the Home Screen
How to Handle Screen Orientation Change When Progress Dialog and Background Thread Active
Android Studio: Add Jar as Library
Libraries Do Not Get Added to Apk Anymore After Upgrade to Adt 22
Why 'Pageradapter::Notifydatasetchanged' Is Not Updating the View
Exception 'Open Failed: Eacces (Permission Denied)' on Android
Difference Between Getcontext() , Getapplicationcontext() , Getbasecontext() and "This"
How to Handle Button Clicks Using the Xml Onclick Within Fragments
"R Cannot Be Resolved to a Variable"
Android: Difference Between Parcelable and Serializable
How to Make a Custom Keyboard in Android
Getting Exception "Illegalstateexception: Can Not Perform This Action After Onsaveinstancestate"
How to Detect When Wifi Connection Has Been Established in Android
Failed to Resolve: Com.Android.Support:Appcompat-V7:26.0.0
Environment.Getexternalstoragedirectory() Deprecated in API Level 29 Java