In my app I use MediaMuxer to create a video file. Constructor of MediaMuxer requires absolute path of output file. Everything is ok with primary storage, but for secondary storage app doesn't work. As I check, in Lollipop user has to pick output directory in external storage, using new Intent ACTION_OPEN_DOCUMENT_TREE (How to use the new SD card access API presented for Android 5.0 (Lollipop)?) But on result of this Intent we get DocumentFile. I don't know how to create new video file with MediaMuxer and this DocumentFile. Can someone help me?
1 Answers
1
votes
There is a method createFile(String mimeType, String displayName)
- just call it on the DocumentFile directory instance:
DocumentFile newFile = documentFileDir.createFile("application/octet-stream", fileName);
OutputStream os = getContentResolver().openOutputStream(newFile.getUri());
... // write your data