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
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..
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.