Android文件递归遍历

if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {    //判断SD卡是否可用
            File file = new File(path);
            File[] files = file.listFiles();
            for (File filename : files) {
                if (filename.isDirectory()) {    //如果是文件夹
                //递归
                    btnLoad(filename.getAbsolutePath());
                } else {
                    String[] filePath = filename.getName().toString().split("\\.");
                    if (filePath.length == 2) {
                        if (filePath[1].equals("mp3") || 
                        }
                    }
                }
            }
        }

你可能感兴趣的:(Android,android,递归)