I am having trouble using picasso on android studio.
I am using picasso for loading the image from my database
Here's my code for loading my image
String resultImageUrl = removeCharAt(pImage,31);
Picasso.get().load(resultImageUrl).into(image_profile);
The problem with the code above is that it doesn't work but if hardcode the path
Picasso.get().load("http://192.168/254/123/myapp/admin/images/12378123asdjh.jpg").into(image_profile);
That code loads the image. What should I do?
I already tried doing it like this
String newUrl = "\"http://" + resultImageUrl + "\"";
Picasso.get().load(newUrl).into(image_profile);
But no luck
If you have a string:
resultImageUrl = "192.168/254/123/myapp/admin/images/12378123asdjh.jpg";
that you want to prefix with http://
, then you can use String#format
:
String.format("http://%s", resultImageUrl);
Edit: An interesting alternative could also be to use a Uri.Builder
, although it's better when you have each individual path segment:
final String url = new Uri.Builder()
.scheme("http")
.path(resultImageUrl)
.build().toString();