How to get bitmap from a url in android?

May 6, 2022

I have a uri like which has an image


How to use this uri to get the image but it returns null, please tell me where i am wrong.

Bitmap bitmap = BitmapFactory.decodeFile(uri.getPath());

Simple way to do

This is a simple one line way to do it:

try {
URL url = new URL("http://....");
Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch(IOException e) {




Curated Solutions On Popular Questions — On All Programming Languages, Cloud Computing, Tools etc