zoukankan      html  css  js  c++  java
  • android 获取所有SD卡目录

    //返回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;
    }
  • 相关阅读:
    寒假 学习进度七
    寒假学习进度
    寒假学习进度五
    寒假学习进度四
    寒假学习进度三
    寒假学习进度二
    Spark实验五
    半篇论文笔记
    REPL
    Scala基本语法及操作、程序控制结构
  • 原文地址:https://www.cnblogs.com/agilezhu/p/7698532.html
Copyright © 2011-2022 走看看