0
public static final String paths = "/storage/" ;

public ArrayList<HashMap<String, String>> getpaths(){
    if (paths != null) {
        File x= new File(paths);
        File[] listFiles = x.listFiles();
        if (listFiles != null && listFiles.length > 0) {
            for (File file : listFiles) {

                if (file.isDirectory()) { 
                    scanDirectory(file);  
                } else {
                    fileFilter(file); 
                }
            }
        }
    }

That is my function to list files from /storage.

My question is: do all android phones have /storage/a/b/c ?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Jakozo
  • 58
  • 10
  • 1
    http://stackoverflow.com/questions/2421826/what-is-androids-file-system – JBA Mar 14 '14 at 12:20
  • Read through http://developer.android.com/guide/topics/data/data-storage.html and http://developer.android.com/training/basics/data-storage/ – indivisible Mar 14 '14 at 12:35
  • I am not an Android dev. but i guess @mbs just showed up with the "generic" way of handling the internal storage of the Android System ;) – JBA Mar 14 '14 at 12:37
  • Without knowing more about the design of the app and what the OP is trying to achieve/store at that location all I can do is offer a generic answer. For instance, if they are trying to store temp data I'd point to the internal cache, for persisting database type data; the internal data storage, for larger files such as image thumbnails; the external "SD Card" location. It all depends on the usage. One thing I'll add is if you want to use the SDCard to store data PLEASE do not make a new folder in the root. Use the /data folder. It's a pet peeve of mine when devs mess w/ my tidy folder struct. – indivisible Mar 14 '14 at 12:45

1 Answers1

2

No, folder hierarchy is same but root of sd-card can be mounted somewhere else and your program would not work. Use:

File paths = Environment.getExternalStorageDirectory();

to get root of sd-card and your program will work on all phones.

EDIT: For example I have CM 11 ROM and Kernel which uses different layout than on other phones.

Dejan
  • 3,046
  • 3
  • 28
  • 43
  • I was using getexternal... But then my app See Just sdcard0 whhich is internal memmory. I want both sdcard0 and sdcard1 which is external – Jakozo Mar 14 '14 at 16:25