This code works quite well but it only detects JPG and not PNG
public String[] getImageFileList(String path_to_directory){
File file = new File(path_to_directory);
if(!file.exists())return null;
String[] images = file.list(new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
boolean result;
File file = new File(current, name);
String mimeType = new MimetypesFileTypeMap().getContentType(file).split("/")[0];
result = mimeType.equals("image");
return result;
}
});
return images;
}
How can I make it detect PNG images too?
EDIT: When checking closer the "result" will become "image" for JPG and "application" for PNG. Am I right in guessing that the PNG is not the only file-type that has that "application" mimeType?