How to read images from drawable folder, not by R.drawable.[imageid]

来源:互联网 发布:linux就该这么学 知乎 编辑:程序博客网 时间:2024/06/05 01:17
public void getImageFoldes(String filepath){
       
        File file = new File(filepath);    
        File[] files = file.listFiles();
        for (int fileInList = 0; fileInList < files.length; fileInList++)  
        {
            File filename;
            filename =files[fileInList];        
            if(filename.isHidden()|| filename.toString().startsWith("."))
                return;               
                if (files.length !=0){
                    //if File is the image file then store the album name
                    if ((files[fileInList].toString()).contains(".png")||
                            (files[fileInList].toString()).contains(".jpg")||
                            (files[fileInList].toString()).contains(".jpeg")){
                        
                        Bitmap myBitmap = BitmapFactory.decodeFile(files[fileInList].getAbsolutePath()); // this is the image file path
                       

                       
                    }       
                }
            
        }
    }


原创粉丝点击