当前位置: 动力学知识库 > 问答 > 编程问答 >

Android - Best way to query device for all folders containing images

问题描述:

Im trying to figure out the best way to get all the directories on a device that contain image files. I know how to use all the api's but my application calls for using an in app image gallery rather than just using an intent to launch the gallery. Ive thought of going through the entire device and looking in the directories and check for extensions but that would take a couple seconds to long. Does any one have a better solution? I already have a very solid custom gallery built but my only problem is coming up with a nice solution to get all the images in other places that my app wont know about.

网友答案:

apache commons-io DirectoryWalker

public class ImagesFinder extends DirectoryWalker{

protected boolean handleDirectory(File directory, int depth, Collection results) {
 return true; 
}

 protected void handleFile(File file, int depth, Collection results) {
      // 
}
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: