i am using following code
Integer val = myReceipt.receiptId ;
String fileName = "image" + "_" + title.getText().toString()+"_" + val.toString();
photo = this.createTemporaryFile(fileName, ".jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
uriOfPhoto = Uri.fromFile(photo);
startActivityForResult(intent, RESULT_CAMERA_SELECT);
}
}
private File createTemporaryFile(String part, String ext) throws Exception
{
File tempDir = new File (Environment.getExternalStorageDirectory() + "/Catch All Keeper/Receipts");
if(!tempDir.exists())
{
tempDir.mkdir();
}
tempDir.canWrite();
return File.createTempFile(part, ext, tempDir);
}
});
Now, it should give name to file image_title_val but it gives a strange name as image_title_(some random numbers).jpg
Can anyone tell what is the problem here?
You are using File.createTempFile to get a unique name. That function assigns the random numbers you see. The fileName string passed in parameter part is used as a prefix to generate the temporary file name.