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
Create a static list of possibilities you've already gotten.
static ArrayList listIdontWantAnymore = new ArrayList();
int NextRandomNumber() {
Random random = new Random();
int myRandomInt;
do {
myRandomInt = random.NextInt(6) + 1;
} while(listIdontWantAnymore.Contains(myRandomInt));
listIdontWantAnymore.Add(myRandomInt);
// now your 'myRandomInt' is what you want it to be.
return myRandomInt;
}