3

Is there any way to get the absolute path from specific Folders & Files located in the removable SD-card, using the Storage Access Framework (SAF)?

Thanks

Floern
  • 33,559
  • 24
  • 104
  • 119
PerracoLabs
  • 16,449
  • 15
  • 74
  • 127
  • maybe this can help -- http://stackoverflow.com/questions/20067508/get-real-path-from-uri-android-kitkat-new-storage-access-framework – Tasos Jan 03 '16 at 13:29

1 Answers1

1

No, and even if you could, you would not be able to access them, unless they happened to be in one of the couple of locations on removable media for which you have read access (e.g., getExternalFilesDirs()).

The Storage Access Framework returns Uri values pointing to documents. Use ContentResolver and methods like openInputStream() to work with them. This is roughly equivalent to getting URL values pointing to documents and using an HTTP client to open a stream to work with the contents of those documents.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    The problem is that openInputStream is not suitable for everything. The MediaMuxer class is a good example as it requires an file absolute path as a target, so the way it is now MediaMuxer can only be used pointing to the internal storage. – PerracoLabs Jan 03 '16 at 13:44
  • 1
    @PerracoLabs: `MediaMuxer` also does not work with URLs, then. Hence, you would handle the Storage Access Framework scenario the same way that you would handle the Web scenario. I have never used `MediaMuxer`, but from a quick scan of the docs, the only place where I see files involved is in the writing of output. So, you have `MediaMuxer` write to internal storage first, transferring it to the `OutputStream` from the `Uri`/URL when the, um, muxing is done. – CommonsWare Jan 03 '16 at 13:48
  • @CommonsWare what if I have phone memory 6 gb free and SD card memory 32 GB, I'm recording video for hours and it's going to be about 10 GB, how I'm supposed to write to internal storage first when it has only 6 GB free? also moving would take a lot of time anyway – user924 May 03 '18 at 13:36
  • @user924: "how I'm supposed to write to internal storage first when it has only 6 GB free?" -- record in chunks (say, 2GB per file), transferring a recorded chunk while recording the next. Or, record to the locations available to you on the removable storage (e.g., `getExternalMediaDirs()`), though I would not try to record a single 10GB file, as that may not be supported by the filesystem on the removable storage. – CommonsWare May 03 '18 at 13:39
  • @CommonsWare I tried FFmpeg JavaCV which can directly record to sd card using `OutputStream` but it has next issues which I can't solve https://github.com/bytedeco/javacv/issues/839 seeking isn't working and it can't determine the length of the video and I can record only in MKV but not MP4 to SD Card using this way – user924 May 03 '18 at 13:52
  • @user924: So, record to the locations available to you on the removable storage (e.g., getExternalMediaDirs()). If needed, move the file to another location on the removable storage afterwards. – CommonsWare May 03 '18 at 13:57