1

I would like to get external root path. I got it like that:

root = File(Environment.getExternalStorageDirectory().absolutePath)

but after release android 10 it has become deprecated. I know that you will say that here I could find a lot of solutions but I didn't manage to solve my problem :( The most popular solution is that:

ContextCompat.getExternalFilesDir(String)

but this solution didn't help me. I also saw these questions: question_1,question_2 and documentation. The one solution which I see is to write smth like that: /storage/emulated/0/ and maybe it will do what I want. But maybe you have better solution for this task?

Andrew
  • 1,947
  • 2
  • 23
  • 61
  • try this. `String path = Environment.getExternalStorageDirectory() + "/Dirname"; File dir = new File(path);` – mili2501 Jan 25 '20 at 10:35
  • getExternalStorageDirectory is deprecated as you know :( – Andrew Jan 25 '20 at 10:36
  • have you check this out. https://stackoverflow.com/questions/57116335/environment-getexternalstoragedirectory-deprecated-in-api-level-29-java – mili2501 Jan 25 '20 at 10:40
  • @mapy, and as I see it returns smth like `/storage/emulated/0/Android/data/com.example.my/files` but I need another path as you can at my question – Andrew Jan 25 '20 at 10:47
  • "I would like to get external root path" -- why? The value is useless to you on Android 10+, as you cannot use it for reading or writing files. – CommonsWare Jan 25 '20 at 12:04
  • @CommonsWare, so this `/storage/emulated/0/` path is useless? – Andrew Jan 25 '20 at 12:35
  • You cannot read or write to that location, so I do not know what you would use it for. – CommonsWare Jan 25 '20 at 12:37
  • @CommonsWare, I use this location for moving for ex to downloads directory or to smth else :) – Andrew Jan 25 '20 at 12:38
  • Well, [you cannot do that anymore using the filesystem](https://commonsware.com/blog/2019/06/07/death-external-storage-end-saga.html). Your choices are using the Storage Access Framework or possibly `MediaStore`. See [this blog post series](https://commonsware.com/blog/2019/10/19/scoped-storage-stories-saf-basics.html) for more on those two approaches. – CommonsWare Jan 25 '20 at 12:48

0 Answers0