标签:dir 判断 ace gem 排除 cto sdi irf tor
//返回sd卡路径
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()) {
//判断是否目录,并排除系统虚拟出来的目录
pathList.add(path);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return pathList;
}
标签:dir 判断 ace gem 排除 cto sdi irf tor
原文地址:http://www.cnblogs.com/agilezhu/p/7698532.html