0

I have to fetch all duplicate images from device (from internal and external storage both) and list them into group wise and delete as per choice. I need to implement functionality like this app Click to see

I tried this method:

  public static List<String> findDuplicatesForDeletion(String directoryPath) {
    List<Map<String, Integer>> pairs = findDuplicateImagePairs(directoryPath);
    List<String> output = new ArrayList();
    boolean isFirstElementInPair = true;
    if(null != pairs && !pairs.isEmpty()) {
        Iterator i$ = pairs.iterator();

        while(true) {
            Map pair;
            do {
                do {
                    if(!i$.hasNext()) {
                        return output;
                    }

                    pair = (Map)i$.next();
                } while(pair.isEmpty());
            } while(pair.keySet().size() <= 1);

            List<Entry<String, Integer>> pairEntryList = new ArrayList(pair.entrySet());
            Collections.sort(pairEntryList, new Comparator<Entry<String, Integer>>() {
                public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
                    return ((Integer)o2.getValue()).compareTo((Integer)o1.getValue());
                }
            });
            isFirstElementInPair = true;
            Iterator i$ = pairEntryList.iterator();

            while(i$.hasNext()) {
                Entry<String, Integer> entry = (Entry)i$.next();
                if(isFirstElementInPair) {
                    isFirstElementInPair = false;
                } else {
                    output.add(entry.getKey());
                }
            }
        }
    } else {
        return null;
    }
}
Mohd Saquib
  • 580
  • 4
  • 14
  • It's a good question, but now it looks like zero-effort question. Please show what is the problem and what you had tried before. We will not write code instead of you. – Northern Poet Dec 21 '17 at 07:20
  • you will have to compare the images id and their name in order to find out the duplication. – Reyansh Mishra Dec 21 '17 at 07:23
  • @NorthernPoet i am trying since last 3 days, first i get all files then convert them into byte array then using this byte array i get its hash value and a little bit code i have mentioned in my question. so please help if possibble – Mohd Saquib Dec 21 '17 at 07:25
  • First of all, what's wrong with your code? Raises an error of not working or working wrong? I mean, edit your question to provide more information to help us help you. – Northern Poet Dec 21 '17 at 07:28
  • @ReyanshMishra how do i compare id , any reference can you provide – Mohd Saquib Dec 21 '17 at 07:31
  • @NorthernPoet i follow steps given in https://stackoverflow.com/questions/34333653/scan-duplicate-document-with-md5 but not getting actual result just get list of images – Mohd Saquib Dec 21 '17 at 07:33

0 Answers0