My app has ability to select photo from library. Exactly I want file path from this selection.
This is the code to create intent for selecting photo:
This is most certainly a workaround, but you could extract the real content URI which has apparently become embedded for some reason: content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F75209
I was able to create a new URI with authority=media and path=external/images/media/xxx, and content resolver returned a real URL.
Example code:
String unusablePath = contentUri.getPath();
int startIndex = unusablePath.indexOf("external/");
int endIndex = unusablePath.indexOf("/ACTUAL");
String embeddedPath = unusablePath.substring(startIndex, endIndex);
Uri.Builder builder = contentUri.buildUpon();
builder.path(embeddedPath);
builder.authority("media");
Uri newUri = builder.build();