Snippet

Encoding URL is very straightforward, simply call the encode method of the URLEncoder class on the String data that you want to encode.

  1. try {  
  2.   String url = "http://www.yoursite.com/blah";
  3.   String queryString = "param=1&value=2";  
  4.  
  5.   String encodedQueryString = URLEncoder.encode(queryString,"UTF-8");
  6.  
  7.    encodedUrl = url + "?" + encodedQueryString;
  8.  
  9.    Log.d("Enc URL: " + encodedurl);
  10.  }
  11.  catch (UnsupportedEncodingException e)
  12.  {
  13.   Log.e("Exception: " + e.getMessage());
  14.  
  15.  }