Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show all root directory path of my android device from external and internal memory..
and i want to search particular folder from that list..
and my folder locate on external memory.

i am trying some code but its not working for all device..

below code for getting a list of all folders and file

Java
searchTXT(new File(Environment.getExternalStorageDirectory().getPath()));

private void searchTXT(File dir){
        File[] files = dir.listFiles();

        for (File file : files) {
            if(file.isFile() && isTXT(file)){
                allTXT.add(file);
                Log.i("TXT", file.getName());
            }else if(file.isDirectory()){
                searchTXT(file.getAbsoluteFile());
            }
        }

private boolean isTXT(File file){
        boolean is = false;
        if(file.getName().endsWith(".mp4")){
            is = true;
            Log.e("", "mp4 files -->"+is);
        }
        return is;
    }

In some devices it will get all external folder and file.. but for some device it will not working..


Below code for getting root path of sdCard ,external memory..

Java
 final String rawExternalStorage = System.getenv("EXTERNAL_STORAGE");

final String   rawSecondaryStoragesStr = System.getenv("SECONDARY_STORAGE");

final String rawEmulatedStorageTarget = System.getenv("EMULATED_STORAGE_TARGET");

following code also work for some device.. i am not getting SECONDARY_STORAGE path from all device..

Plz help me out for this quire..
thanx in Advance.
Posted
Updated 27-Apr-15 21:48pm
v2
Comments
Richard MacCutchan 28-Apr-15 3:49am    
What does "not working" mean? Have you used your debugger to identify what is happening in each case?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900