views:

159

answers:

2

How can I convert a String to a Uri in Java (Android)? i.e.:

String myUrl = "http://stackoverflow.com";

myUri = ???;

+2  A: 

You can use the parse static method from Uri

Uri myUri = Uri.parse("http://stackoverflow.com")
ccheneson
+1  A: 

What are you going to do with the URI?

If you're just going to use it with an HttpGet for example, you can just use the string directly when creating the HttpGet instance.

HttpGet get = new HttpGet("http://stackoverflow.com");
Stuart Grimshaw