列出 sdcard 中的所有文件
if (folder.listFiles() != null) {
for (File file : folder.listFiles()) {
if (file.isFile()) {
Log.v("vvv", "file with name " + folder.getName() + " in path " + folder.getAbsolutePath());
}
}
}
这会打印类似这样的内容
/vvv ( 3940): Folder with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): Folder with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
我在代码中做了一些白痴的事情,但我不知道是什么...
我想列出SD卡中的所有文件夹和所有文件...
你能帮我找到我的错误吗,谢谢
if (folder.listFiles() != null) {
for (File file : folder.listFiles()) {
if (file.isFile()) {
Log.v("vvv", "file with name " + folder.getName() + " in path " + folder.getAbsolutePath());
}
}
}
This prints something like this
/vvv ( 3940): Folder with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): file with name .thumbnails in path /sdcard/DCIM/.thumbnails
V/vvv ( 3940): Folder with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
V/vvv ( 3940): file with name Camera in path /sdcard/DCIM/Camera
I do some idiotic thing in the code, but I do not know what...
I want to list all the folders and all the files from the sdcard...
can you help me found my bug, Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能指的是
file.getName()
。You probably meant
file.getName()
.