To save as another name just change the string "capture.jpeg"
If you want to have it as cafeXXX.jpeg (where XXX is a number) then you could do something like this (this method could potentially cause number overlaps however if files are deleted):
int count = 1;
File picturesDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File[] content = picturesDir.listFiles();
for (File f: content)
{
if (f.getName().matches("cafe\d+\.jpeg"))
count++;
}
//... your other code
// if leading zeros important then add formatting code to the count
fos = new FileOutputStream(picturesDir.toString() + "cafe"+count+".jpeg");
If you want a timeformat just use SimpleDateFormat changing the format String as required (as only going to day will mean you will only get time format per day)
String timeFileName = new SimpleDateFormat("yyyy-MM-dd").format(new Date())
//...other code
fos = new FileOutputStream(picturesDir.toString() + timeFileName+".jpeg");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…