title: How to get Android storage locations
body: <p>I'm struggling with something that should be dead simple which is the dreaded problem of getting the storage directory paths, be it internal or exteral -- SD cards or OTG devices -- .</p>
  
  <p>​</p>
  
  <p>I was expecting a simple call such as getExternalStorageDirectory() or something of the like , but to my surprise I found I had to do a lot of hacks and workarounds to guarantee that my function works with all OEMs and different versions of Android.</p>
  
  <p>​</p>
  
  <p>I found a solution here which uses the following three Environment Variables</p>
  
  <p>val rawExternalStorage = System.getenv("EXTERNAL_STORAGE")</p>
  
  <p>val rawSecondaryStoragesStr = System.getenv("SECONDARY_STORAGE")</p>
  
  <p>val rawEmulatedStorageTarget = System.getenv("EMULATED_STORAGE_TARGET")</p>
  
  <p>I kinda get what the first and second variables are -- but with Android, never be sure of anything! :D --</p>
  
  <p>But I've absolutely no idea what the third variable is or what it does ,, could someone please explain to me what it is and how I should use it?</p>