I have an ArrayList of an object from where I want items of a particular position, but everytime I launch the Activity the retrieved position should be randomize and also won't repeat until every position Item is completely retrieved. I used this method:
public static int getRandomNumber(ArrayList<Integer> arr)
            throws IllegalArgumentException {
        try {
            Random random = new Random();
            int select = random.nextInt(arr.size());
            int randomnum = arr.get(select);
            GlobalData.randList.remove(select);
            return randomnum;
        } catch (IllegalArgumentException e) {
            for (int i = 0; i < arr.size(); i++) {
                GlobalData.randList.add(i);
            }
            return 0;
        }
but its not working,like duplicate number is coming, there may be a reason because everytime I am re launching the activity. I did it in oncreate instead of onResume but its not working as I expected? Is there any other way to work with it? Any solution?
 
     
     
    