Question

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top