URL encoding in Android -


How do you encode in Android?

I thought it was like this:

  last string encoded URL = url encoder.x code (urleststring, "UTF-8"); URL url = new URL (encoded URL);  

If I above, then urlAsString in http: // to http% 3A% 2F% 2F < / Code> these encoded URLs and then I get a java.net.malformedURLException when I use URL.

You do not change the whole URL in sign language, only that part comes from "untrusted source" Are there.

  String query = URLEncoder.encode ("apple orange", "UTF-8"); String url = "http://stackoverflow.com/search?q=" + query;  

Alternatively, you can use that exception is not checked.

or something like this

  string uri = URI .parse ("http: // ...") .buildUpon () .appendQueryParameter ("key", "Val") .build (). ToString ();  

Comments