2

what is wrong with android storage access hierarchy?All i want to do is to make a file explorer app which could show user a list of all the files on their device and memory card(if available), but its been days and i cannot find a proper way for that.

I checked all the Environment class methods and context.getFileDir()/other methods of ContextCompat , but they either point to emulated storage or the app's folder, but not the sd card. I have scratched my head and pulled all my hairs out researching a lot deep into this area, but found nothing. The only thing that works sometime is the hardcoded paths( eg new File("/sdcard") ) , but that looks like a terrible hack and i know its not good.

I have also read briefly about Storage Access Framework, but i don't think that's what I want. From what i know, SAF works in the following manner : user opens my app>>clicks on a button>>my app fires an intent to SAF>> SAF opens its own UI>>user selects 1 or multiple file>> and my app recieves those file uris. THAT'S A FILE PICKER, AND I DON'T WANT THAT.

I want the user to see a list of his files in my app only. Because if not, then what's the point of my app with the title "File explorer"?

Comments
  • 0
    There are a number of open source file managers already
  • 0
    I've got a single Java class that'll run through your android files.... I could send in a pm or email
  • 0
    @crapped i have the files permission. And the method you are saying is correct. But this is actually considered a bad practice since every android won't have the exact same directory location. For eg in 1 of my two phones, memory card directory is accessed using "/storage/sdcard1" path while my other, slightly older device has "mnt/sdcard/0" as the location of sdcard

    I have actually done a lot of research on this which all points out to the fact that evolution of Android has greatly fucked the storage hiarchy and symbolism of removable storage .
  • 0
    @martygeek paste your code on pastebin and put the link here.. i would really like to check that code
  • 0
    @crapped Yeah as i said, i checked that already. Environment.getExternalStorageDirectory() is the function returning the "external" storage . and android's fucked up situation is that "external" could either mean an emulated non removable storage or a removable storage. So this function is returning a file for 1 of the 2 locations, but not both( what's even dumber is the fact that the return value varies from device to device)

    I actually want to show both for devices like samsung and mi which are having good internal memory with sd card support , but there is no function in Environment class giving both of their locations.
  • 0
    Oh dang
    I got busy.... Lemme paste some code
  • 0
Add Comment