how to insert %20 in place of space in android
Try this:
String temp = http://www.arteonline.mobi/iphone/output.php?gallery=MALBA%20-%20MUSEO%20DE%20ARTE%20LATINOAMERICANO%20DE%20BUENOS%20AIRES
temp = temp.replaceAll(" ", "%20");
URL sourceUrl = new URL(temp);
When you build your URL you should use URLEncoder to encode the parameters.
StringBuilder query = new StringBuilder();
query.append("gallery=");
query.append(URLEncoder.encode(value, "UTF-8"));
If you already have the whole URL in a String or a java.net.URL, you could grab the query part and rebuild while URLEncoding each parameter value.
Just one addition to sudocode's response:
Use android.net.Uri.encode
instead of URLEncoder.encode
to avoid the "spaces getting converted into +" problem. Then you get rid of the String.replaceAll()
and it's more elegant :)
StringBuilder query = new StringBuilder();
query.append("gallery=");
query.append(android.net.Uri.encode(value));