how to get random item from an arraylist without any repeatation in android
<p>I have an <code>ArrayList</code> 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:</p>

<pre><code>public static int getRandomNumber(ArrayList&lt;Integer&gt; 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 &lt; arr.size(); i++) {

                GlobalData.randList.add(i);

            }
            return 0;
        }
</code></pre>

<p>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 <code>oncreate</code> instead of <code>onResume</code> but its not working as I expected? Is there any other way to work with it? Any solution?</p>
