我想将所有文件保存在一个特定的文件夹中。谁能给我一个建议,如何使用管理查询来查询特定文件夹中的所有文件。
试试这个
ArrayList<File> mFiles = new ArrayList<File>();
File mDirectory;
String folderPath = "/mnt/sdcard/download";
mDirectory = new File(folderPath);
ExtensionFilenameFilter filter = new ExtensionFilenameFilter(acceptedFileExtensions);
// Get the files in the directory
File[] files = mDirectory.listFiles(filter);
if (files != null && files.length > 0) {
for (File f : files) {
mFiles.add(f);
}
Collections.sort(mFiles, new FileComparator());
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句