Screenshoti am working on App in which i take pictures from camera, and save that picture in root directory of android, everything is working fine the problem that i am facing is with its name , when the file is getting save the function in Concatenating extra Number with it,
@SuppressLint("SimpleDateFormat") private File getImageFile() throws IOException {
timeTicks = new SimpleDateFormat("ddMMMyyyy_hhmmss-").format(new Date());
imageName = "img-" + timeTicks; //30Nov2021_105137-
storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
imageFile = File.createTempFile(imageName, ".jpg", storageDir); //storage/emulated/0/Android/data/com.example.meterreadingrecord/files/Pictures/img-30Nov2021_105137-3304015006530902745.jpg
imageName = imageFile.getName();
currentImagePath = imageFile.getAbsolutePath();
return imageFile;
return imageFile;
}
3304015006530902745.jpg This extra Time tick is getting concatinate with the file name that i am creating,
Anyone can help me this?? please
Thanks alot in advance
As suggested in blackapps comment, using
File imageFile = new File(getExternalFilesDir(Environment.DIRECTORY_PUCTURES), fileName);
instead of
imageFile = File.createTempFile(imageName, ".jpg", storageDir);
solves the problem.