如何找到具有一定的扩展Android上的所有文件?

编程入门 行业动态 更新时间:2024-10-24 01:50:50
本文介绍了如何找到具有一定的扩展Android上的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用的是fileBrowser找到手机上的文件,但是我想表明,我的应用程序可以打开该用户的所有文件,然后用户选择之一。像音乐播放器,即显示出的所有歌曲在电话上的SD卡和在内部存储器中,不仅那些在文件夹中,其中用户是

I'm using a fileBrowser to find the files on the phone, but I wanted to show all files that my app can open to the user, and then the user chooses one. Like the Music Player, that show all songs on phone, on the sdcard and in the internal memory, not only the ones in the folder where the user is.

推荐答案

使用文件名过滤器,同时列出了这些文件。下面的示例列出了所有的MP3文件在给定的根目录(注 - 低于code没有在根) -

Use file name filters while listing out the files. The below sample lists out all mp3 files in a given root directory (Note - The below code doesn't do it recursively for all folders under root) -

String files[] = root.list(audioFilter); FilenameFilter audioFilter = new FilenameFilter() { File f; public boolean accept(File dir, String name) { if(name.endsWith(".mp3") || name.endsWith(".MP3")) { return true; } f = new File(dir.getAbsolutePath()+"/"+name); return f.isDirectory(); } };

更多推荐

如何找到具有一定的扩展Android上的所有文件?

本文发布于:2023-11-30 02:54:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648483.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有一定   文件   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!