Back to SD card path
public static list<string> Getstoragedirectories (context context) {
StorageManager sm = (StorageManager) context.getsystemservice (Context.storage_service);
list<string> pathList = new arraylist<> ();
File exdirfile = Environment.getexternalstoragedirectory ();
String externalstoragedir = "";
if (exdirfile! = null) {
Externalstoragedir = Exdirfile.getabsolutepath ();
}
try {
String[] paths = (string[]) Sm.getclass (). GetMethod ("getvolumepaths", null). Invoke (SM, null);
if (paths! = null && paths.length > 0) {
for (String path:paths) {
File File = new file (path);
if (! Textutils.isempty (path) &&!path.equalsignorecase (externalstoragedir) && file.isdirectory ()) {
Determine whether the directory and exclude the system virtual out of the directory
Pathlist.add (path);
}
}
}
} catch (Exception e) {
E.printstacktrace ();
}
return pathList;
}
Android get all SD card directory