I am trying to get image from gallery and setting up it on ImageView , Hear is okay well i get and set image on ImageView, but now i want to check
ArrayList filePaths = new ArrayList<>();
ArrayList newFilePath = new ArrayList<>(); //for storing file path which size is less than 100 KB
if (imagePaths != null) {
filePaths.addAll(imagePaths);
for (int i = 0; i < filePaths.size(); i++) {
File file = new File(filePaths.get(i));
int file_size = Integer.parseInt(String.valueOf(file.length() / 1024)); //calculate size of image in KB
if (file_size < 100)
newFilePath.add(filePaths.get(i)); //if file size less than 100 KB then add to newFilePath ArrayList
}
}
Here imagePaths stores path of all images that we have selected. Then if imagePaths is not null then add all images path in filePaths. You can use this code for document type of file also.