扫描一个文件夹中的Andr​​oid文件路径 [英] Scan a file folder in android for file paths

查看:95
本文介绍了扫描一个文件夹中的Andr​​oid文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个文件夹,在MNT / SD卡/文件夹,其填充的图像文件。我希望能够扫描的文件夹,并为每个那就是把每个文件路径中一个ArrayList文件夹中的文件。有没有一种简单的方法来做到这一点?

So i have a folder at "mnt/sdcard/folder" and its filled with image files. I want to be able to scan the folder and for each of the files that is in the folder put each file path in an arraylist. Is there an easy way to do this?

推荐答案

您可以使用

List<String> paths = new ArrayList<String>();
File directory = new File("/mnt/sdcard/folder");
File[] files = directory.listFiles();
for (int i = 0; i < files.length; ++i) {
    paths.add(files[i].getAbsolutePath());
}

请参阅<一href="http://download.oracle.com/javase/1.5.0/docs/api/java/io/File.html#listFiles%28%29"><$c$c>listFiles()在变种文件

这篇关于扫描一个文件夹中的Andr​​oid文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆