public static File[] filenames;
public static ArrayList<String> shortFilenames;
public static String MyDirectory = "/AudioSamples";
public static ArrayList<String> getFileNames() {
File sdCardRoot = new File(Environment.getExternalStorageDirectory() + MyDirectory);
filenames = sdCardRoot.listFiles();
shortFilenames = new ArrayList<String>();
for (File tmpf : filenames) {
String name = tmpf.getName();
shortFilenames.add(name);
}
return shortFilenames;
}
我只需要从 sd 卡上的目录中获取音乐文件(如 m4b、mp3)和包含音乐/声音的文件夹的名称,我该怎么做?我的代码需要一切,所以我需要某种过滤器:)