I'm recording video with the aid of android.media.MediaRecorder
class, which accepts path string for output file (MediaRecorder.setOutputFile(String)
), though there is a version of the method which accepts FileDescriptor
.
I need to store huge video files, so I want to use SD card. In order to get path to relevant directory I use Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)
. It turns out that resulting path is for the “emulated” storage (/sdcard/…
) instead of real SD card (/sdcard1/
on my Xperia Z3 Compact, Android 5.1.1).
I tried to hardcode /sdcard1/
(as well as /storage/sdcard1
) but get an IOException
talking about permission deny. Of course, I have
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I heard about huge changes in access to SD card after 4.4 (aka Storage Access Framework), but couldn't find simple and clear enough explanation on how to get things done in such a case. Any help on short and concise solution for this?
PS Solution with hardcoded path would be OK for me as I'm going to use this app only with my phone.