I create a file and save an image to it using the following code:
private File createImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getActivity().getApplicationContext().getFilesDir();
File image = File.createTempFile(imageFileName, ".jpg", storageDir);
return image;
}
When I use image.getAbsolutePath();
, I get somwthing like this:
/data/data/co.za.package.app/files/filename.jpg
The actual path of the image is:
/storage/sdcard0/Android/data/co.za.package.app/files/filename.jpg
Why is getAbsolutePath()
returning the wrong path? I hardcoded the above String
and my image displayed fine. Do any of you have any idea what I'm doing wrong? Thank you in advance