I have looked at the various different versions of this question hear, and have tried some to no success.
In the code its downloading files with
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url.toString()));
request.setDestinationInExternalPublicDir(dirtype, dirPath);
long refid = mDownloadManager.enqueue(request);
with
dirType = Environment.DIRECTORY_DOWNLOADS
dirPath = MyAppCommon.MYAPP_FOLDER + "/attachments/" + attachment.getFile().toLowerCase()
Which puts them in storage/emulated/0/Download/Myapp/attachments/myfile.pdf
I need to delete the folder and all files within when my app starts up, but it will not let me delete. When I list files I only media files (which I understand is part of permission changes)
I have tried the MANAGE_EXETERAL_STORAGE permission and allowing access to all files, and that works but also requires that the app is approved to use it in the playstore, which it probably will not be.
I saw the Storage Access Framework and that seemed to prompt the user about the deletion of a file, but I want this to happen in the background as my app is the one that downloaded and stored these files.