This line:
final FileOutputStream outputStream = new FileOutputStream(name);
results in a FileNotFoundException with the messa
To use internal storage for the application, you don't need permission, but you may need to use: File directory = getApplication().getCacheDir(); to get the allowed directory for the app.
Or:
getCashDir(); <-- should work
context.getCashDir(); (if in a broadcast receiver)
getDataDir(); <--Api 24
Google have restricted write access to the external sdcard. From API 19 there is a framework called Storage Access Framework which allows you the set up "contracts" to allow write access.
For further info:
Android - How to use new Storage Access Framework to copy files to external sd card