Wai Yan Hein Wai Yan Hein - 1 year ago 169
Android Question

Picasso not working if url contains space

I am developing an Android app in which I am retrieving an image from a server and show it in an image view using Picasso. Some image URLs don't work even though I can test them successfully in a browser.

For example this URL works correctly:


But this one fails:

http://www.tonightfootballreport.com/\Filebucket\Picture\image\png\20160807025619_Serie A.png

The difference appears to be that the failing URL contains a space. What do I need to do to make this work?

Answer Source
String temp = "http://www.tonightfootballreport.com/\Filebucket\Picture\image\png\20160807025619_Serie A.png";
temp = temp.replaceAll(" ", "%20");
URL sourceUrl = new URL(temp);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download