OnActivityCreated I'm doing:
activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
In logcat I get:
com.package W/ContextImpl﹕ Failed to ensure directory: /storage/sdcard1/Android/data/com.package/files/Pictures
This happens only on LOLLIPOP (MOTO G 2014), and everything is fine on KITKAT (Nexus 4). I've WRITE_EXTERNAL_STORAGE on manifest. What am I missing here? The storage is mounted and reachable via a file browsing app (like ES Explorer).
EDIT: Surprisingly the file is correctly created under the directory even if I get the warning reported above.
Try this :
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
and use this permission:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Actually:
getExternalFilesDir()
It returns the path to files folder inside /Android/data/com.package/files/Pictures
on your SD card. And there is no folder named Pictures
inside it. So you are getting that error.