I have just encountered a problem I can't seem to fix by myself.
A key element of this application is downloading and storing a file from a url, for which I am using an extension of AsyncTask
This file is eventually saved to
Environment.getExternalStorageDirectory().toString() + "/" + fileName + ".xls")
then a file is created:
File file = new File(Environment.getExternalStorageDirectory().toString() + "/" + fileName + ".xls");
and a stream is made
InputStream is = new FileInputStream(file);
At which point I get a FileNotFoundException ENOENT : no such file or directory.
I have the appropriate permissions set up in my AndroidManifest.xml file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Environment.getExternalStorageState() returns "mounted" value.
And I can confirm internet connection is established, as before I can download any files, I have to log in with appropriate credentials in the app.
I am making this app for API 16, Android 4.1 (Jelly Bean). Any help would be greatly appreciated!
EDIT: I have managed to make make this work on Samsung SM-G800G (Android 5.1.1, API 22). But the application will not run on my Nexus One (Android 6.0, API 23) nor SAMSUNG SM-G900F (Android 6.0.1, API 23).
So there is definitely something going on with how Android versions affect the download, I am looking into it right now.