Convert to

Exception or error:

I am able to find how to convert to here but not vice-versa.

So after spending some time I figured it out. Here is the solution(If there is another solution then please post that as well)

First convert javaURI to string and then use’s parse function androidUri =;
How to solve:

public static Uri parse (String uriString)

Creates a Uri which parses the given encoded URI string.

uriString: an RFC 2396-compliant, encoded URI

Uri for this given uri string

NullPointerException if uriString is null

Therefore, here is an example:"").toString());

Goes without saying, use the real in it… 😉


For anyone coming across this, I had success with the following code:

URI oldUri;
Uri newUri  = new Uri.Builder().scheme(oldUri.getScheme())

Basically, get each URI component and pass it to the builder (as there does not seem to be a way to pass in a whole URI string.


uri = Uri.parse(mFile.toString());

Leave a Reply

Your email address will not be published. Required fields are marked *