I want to get the actual path of an image stored in the gallery of android phone.
In my app, I am selecting an image from the gallery and setting it to an imageView. The reason why I need the path is that later I want to send that image as an attachment through JavaMail.
I am getting quite confused about this.
The image path in my device is:
Internal storage/DCIM/Camera/image_name.jpg
I have used the following method to get the path from the image uri:
String path = imageUri.getPath();
And getting the following result:
raw//storage/emulated/0/DCIM/Camera/image_name.jpg
Now, when I pass the above result as the filepath of the attachment to send, I get the File not found exception
raw//storage/emulated/0/DCIM/Camera/image_name.jpg: open failed: ENOENT (No such file or directory)
With a few trial and errors, the image attachment was successfully sent when I passed the following path as hardcoded string:
/storage/emulated/0/DCIM/Camera/image_name.jpg
I know this type of question has been asked before many times, but I couldn't a satisfactory working answer. I hope, this explanation of my problem might get me the solution.