Android:获取指定文件夹内的所有图片 public static List<String> getFilesAllName(String path){ //传入指定文件夹的路径 File file = new File(path); File[] files = file.listFiles(); List<String> imagePaths = new ArrayList<>(); for(int i = 0; i < files.length; i++){ if(checkIsImageFile(files[i].getPath())){ imagePaths.add(files[i].getPath()); } } return imagePaths; } /** * 判断是否是照片 */ public static boolean checkIsImageFile(String fName){ boolean isImageFile = false; //获取拓展名 String fileEnd = fName.substring(fName.lastIndexOf(".") + 1, fName.length()).toLowerCase(); if(fileEnd.equals("jpg") || fileEnd.equals("png") || fileEnd.equals("gif") || fileEnd.equals("jpeg")|| fileEnd.equals("bmp")){ isImageFile = true; }else{ isImageFile = false; } return isImageFile; }