This is how i am generating a unique no in between 1 to 6 and getting appropriate images from the drawable folder.
Random rand = new Random();
// n = the n
Generate a list of numbers containing every number you will use. (Which is fine, given that we are talking about a small range, where "N" is "somewhere less than a thousand")
When you choose a number, select a random index between 0 and sizeof(list), that number becomes the index of that list.
Delete that list index and return the number.
(It is an exercise to the reader to determine what kind of "list" is appropriate here.)