0

My application need to show media files using direct file paths (ex : /storage/emulated/0/Pictures/example.png), but I am facing some problem as below:

  • With MediaStore: The column MediaStore.MediaColumns.DATA is deprecated
  • With Files API : When I perform sequential reads of media files using direct file paths, I can get the root directory because Environment.getExternalStorageDirectory() is deprecated

Can anyone help me find out the best solution? Thanks advance.

Lee
  • 1
  • 1
  • 2
  • Does this answer your question? [Get real path from Uri - DATA is deprecated in android Q](https://stackoverflow.com/questions/57093479/get-real-path-from-uri-data-is-deprecated-in-android-q) – Ryan M May 20 '21 at 07:07
  • (or in other words: no, there is not a way to do this reliably) – Ryan M May 20 '21 at 07:07
  • Thanks for your answer. I am working with [NanoHttpd](https://github.com/NanoHttpd/nanohttpd) as a simple webserver to serve files, but this library return file as format: `ipAdress:port/{directly file path}`. This is why I need direct file path – Lee May 20 '21 at 07:18
  • Would the relative path do the trick? https://stackoverflow.com/a/58669414/208273 – Ryan M May 20 '21 at 07:21

0 Answers0