I made this code for getting file extensions array for checking if any images are in that folder:
if (file.isDirectory()) {
listFile = file.listFiles();
extension = new String[listFile.length];
for (int i = 0; i < listFile.length; i++) {
FilePathStrings[i] = listFile[i].getAbsolutePath();
FileNameStrings[i] = listFile[i].getName();
int ex = FilePathStrings[i].lastIndexOf('.');
if (ex >= 0) {
extension[i] = FilePathStrings[i].substring(ex+1);
}
}
if (!Arrays.asList(extension).contains("jpg") || !Arrays.asList(extension).contains("jpeg")
|| !Arrays.asList(extension).contains("png")) {
//Do Something
}
But it's always returns true even if there are some images with exact "jpg" extension in the path (the part that gets file path and listfile is 100% working).
I tried with both filename and filepath but non of them worked.