Android URL to Uri

We can parse any URL using Uri.parse(String) method.

Code Snippet :

Uri uri =  Uri.parse( "http://www.stackoverflow.com" );

final String myUrlStr = "xyz";
URL url;
Uri uri;
try {
    url = new URL(myUrlStr);
    uri = Uri.parse( url.toURI().toString() );
} catch (MalformedURLException e1) {
    e1.printStackTrace();
} catch (URISyntaxException e) {
    e.printStackTrace();
}