void addUnique(ArrayList<String> list, String item) { if (!list.contains(item)) { list.add(item); } }If you always do this when appending you won't get any duplicates. If you are given an ArrayList which might have unwanted duplicates I would convert it into a HashSet then back into an ArrayList.
list = new ArrayList<String>(new HashSet<String>(list));