//返回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;
}

最新文章

  1. Spring整合log4j
  2. SpringMVC学习系列(3) 之 URL请求到Action的映射规则
  3. struts2学习笔记之四:多配置文件支持和常用配置参数
  4. http://www.open-open.com/lib/view/open1397274257325.html
  5. storyboard中xib文件不加载问题
  6. UNICODE字符串与多字节字符串的转换
  7. 内存/硬盘/io关系
  8. Locust性能测试工具的安装及实际应用
  9. [物理学与PDEs]第1章第5节 Maxwell 方程组的数学结构, 电磁场的波动性 5.3 电磁场的波动性, 自由电磁波
  10. Windows系统Nessus离线(Offline) 版的安装
  11. C. Brutality Educational Codeforces Round 59 (Rated for Div. 2) 贪心+思维
  12. SQL常见问题积累
  13. Context namespace element &#39;annotation-config&#39; and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
  14. 1.网站应用程序 - 《APS.NET本质论》
  15. IntelliJ IDEA删除代码的注释
  16. Django学习---抽屉热搜榜分析【all】
  17. Python实例---FTP小程序
  18. Linux进程间通信的几种方式总结--linux内核剖析(七)
  19. css 自定义滚动条
  20. BZOJ2668 [cqoi2012]交换棋子 【费用流】

热门文章

  1. python基礎學習第二天
  2. 剑指offer-面试题49-丑数-空间换时间
  3. 安装MongoDB到CentOS(YUM)
  4. Qt读写文件
  5. TTradmin v2.1 【2019年12月12日更新】简单好用的临时远程协助软件
  6. 获取http://XX.XX.XX.XX :XXXX/QuestionResult.aspx?method=接口返回值
  7. Python第三方库requests的编码问题
  8. Flink架构,源码及debug
  9. 产生随机数(rand()函数和srand()函数)
  10. win10中安装与配置maven