在android里面想弄个图片的应用但是每次系统媒体库的图片都不能及时更新,所以改用自己去搜索SDCARD的图片文件,具体实现目标:查找所有包含图片文件的目录 可以是C/C++/java实现的方法 最好最好用C++/C的方法实现 实现思路/代码都可以 在此谢谢各位大侠了

解决方案 »

  1.   

    这个试过可以搜索    public void SearchFiles(File file) {  
         if(file==null) return;
            File[] files = file.listFiles(); 
            if(files==null) return;
            for (File mf : files) {   
            
                if (mf.isDirectory()) { 
                 System.out.println(mf.getPath()); 
                    SearchFiles(mf);   
                } else { 
                 if(file==null) continue;
                    try {  
                     String str=mf.getName().toLowerCase();
                        if (str.endsWith(".bmp") ||str.endsWith(".png") ||str.endsWith(".jpg") ||str.endsWith(".gif") ) 
                        {   
                          System.out.println(mf.getPath());   
                        }   
                    } catch(Exception e) {   
                       e.printStackTrace(); 
                    }   
                }   
            }  
        };    SearchFiles(new File("/sdcard"));