Reputation: 446
been having a rough time with this and don't know why it's not working. Searched around, but couldn't find anything - would appreciate some help.
I'm trying to create a path for an image taken with camera on android however it is giving me:
/mnt/sdcard/[email protected]
I would really appreciate if someone could tell me how to only get the random number without the java.util.Random. Thanks!
My code is as follows:
Random randomGenerator = new Random();
randomGenerator.nextInt(100);
String newimagename = String.valueOf(randomGenerator)+".jpg";
File f = new File(Environment.getExternalStorageDirectory() + File.separator + newimagename);
Upvotes: 0
Views: 58
Reputation: 41281
You need to get the value of nextInt
. You're printing the location of the random number generator's state data itself.
Do:
int rNum=randomGenerator.nextInt(100);
String newimagename =Integer.toString(rNum)+".jpg";
You should also know that with such a low limit you'll run into collisions of filenames.
Upvotes: 5