I am writing this tutorial as lot of people are asking me about loading an image into imageview. Just by adding url to ImageView won’t load directly. Instead we need to store the image into cache (temporary location) and attach to ImageView. This can be achieved just by calling couple of lines and don’t forget to add required classes to your project.

Download Code

1. Create a new project in Eclipse IDE by navigating to File ⇒ New ⇒ Android Project and fill the required details.
2. Inorder to load images from an url we first need to store the image in a temporary location and once it is downloaded it should be added to ImageView. To create a temporary file we need to access device external storage. Add required permission to AndroidManifest.xml file.

To access internet required permission is – INTERNET
To access external storage required permission is – WRITE_EXTERNAL_STORAGE

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

        android:label="@string/app_name" >
            android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
    <!-- Internet Permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Permission to write to external storage -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


3. For testing purpose create a simple ImageView in your main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" >

        android:text="Loading image from url"
        android:layout_margin="10dip" />
    <ImageView android:id="@+id/image"


4. Open your main activity and type the following code. Whenever you wan’t to show an image from url just call the following code.

imgLoader.DisplayImage(image_url, loader, image);
// image_url - is image url path
// loader - loader image, will be shown before loading image
// image - is ImageView
package com.androidhive.imagefromurl;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class AndroidLoadImageFromURLActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        // Loader image - will be shown before loading image
        int loader = R.drawable.loader;
        // Imageview to show
        ImageView image = (ImageView) findViewById(R.id.image);
        // Image url
        String image_url = "https://api.androidhive.info/images/sample.jpg";
        // ImageLoader class instance
        ImageLoader imgLoader = new ImageLoader(getApplicationContext());
        // whenever you want to load an image from url
        // call DisplayImage function
        // url - image url to load
        // loader - loader image, will be displayed before getting image
        // image - ImageView 
        imgLoader.DisplayImage(image_url, loader, image);

5. Add following classes in your project and run the project.

Required Classes


package com.androidhive.imagefromurl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;
public class ImageLoader {
    MemoryCache memoryCache=new MemoryCache();
    FileCache fileCache;
    private Map<ImageView, String> imageViews=Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
    ExecutorService executorService; 
    public ImageLoader(Context context){
        fileCache=new FileCache(context);
    int stub_id = R.drawable.ic_launcher;
    public void DisplayImage(String url, int loader, ImageView imageView)
    	stub_id = loader;
        imageViews.put(imageView, url);
        Bitmap bitmap=memoryCache.get(url);
            queuePhoto(url, imageView);
    private void queuePhoto(String url, ImageView imageView)
        PhotoToLoad p=new PhotoToLoad(url, imageView);
        executorService.submit(new PhotosLoader(p));
    private Bitmap getBitmap(String url)
        File f=fileCache.getFile(url);
        //from SD cache
        Bitmap b = decodeFile(f);
            return b;
        //from web
        try {
            Bitmap bitmap=null;
            URL imageUrl = new URL(url);
            HttpURLConnection conn = (HttpURLConnection)imageUrl.openConnection();
            InputStream is=conn.getInputStream();
            OutputStream os = new FileOutputStream(f);
            Utils.CopyStream(is, os);
            bitmap = decodeFile(f);
            return bitmap;
        } catch (Exception ex){
           return null;
    //decodes image and scales it to reduce memory consumption
    private Bitmap decodeFile(File f){
        try {
            //decode image size
            BitmapFactory.Options o = new BitmapFactory.Options();
            o.inJustDecodeBounds = true;
            BitmapFactory.decodeStream(new FileInputStream(f),null,o);
            //Find the correct scale value. It should be the power of 2.
            final int REQUIRED_SIZE=70;
            int width_tmp=o.outWidth, height_tmp=o.outHeight;
            int scale=1;
                if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
            //decode with inSampleSize
            BitmapFactory.Options o2 = new BitmapFactory.Options();
            return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
        } catch (FileNotFoundException e) {}
        return null;
    //Task for the queue
    private class PhotoToLoad
        public String url;
        public ImageView imageView;
        public PhotoToLoad(String u, ImageView i){
    class PhotosLoader implements Runnable {
        PhotoToLoad photoToLoad;
        PhotosLoader(PhotoToLoad photoToLoad){
        public void run() {
            Bitmap bmp=getBitmap(photoToLoad.url);
            memoryCache.put(photoToLoad.url, bmp);
            BitmapDisplayer bd=new BitmapDisplayer(bmp, photoToLoad);
            Activity a=(Activity)photoToLoad.imageView.getContext();
    boolean imageViewReused(PhotoToLoad photoToLoad){
        String tag=imageViews.get(photoToLoad.imageView);
        if(tag==null || !tag.equals(photoToLoad.url))
            return true;
        return false;
    //Used to display bitmap in the UI thread
    class BitmapDisplayer implements Runnable
        Bitmap bitmap;
        PhotoToLoad photoToLoad;
        public BitmapDisplayer(Bitmap b, PhotoToLoad p){bitmap=b;photoToLoad=p;}
        public void run()
    public void clearCache() {


package com.androidhive.imagefromurl;

import java.io.File;
import android.content.Context;
public class FileCache {
    private File cacheDir;
    public FileCache(Context context){
        //Find the dir to save cached images
        if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
            cacheDir=new File(android.os.Environment.getExternalStorageDirectory(),"TempImages");
    public File getFile(String url){
        String filename=String.valueOf(url.hashCode());
        File f = new File(cacheDir, filename);
        return f;
    public void clear(){
        File[] files=cacheDir.listFiles();
        for(File f:files)


package com.androidhive.imagefromurl;

import java.lang.ref.SoftReference;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import android.graphics.Bitmap;
public class MemoryCache {
    private Map<String, SoftReference<Bitmap>> cache=Collections.synchronizedMap(new HashMap<String, SoftReference<Bitmap>>());
    public Bitmap get(String id){
            return null;
        SoftReference<Bitmap> ref=cache.get(id);
        return ref.get();
    public void put(String id, Bitmap bitmap){
        cache.put(id, new SoftReference<Bitmap>(bitmap));
    public void clear() {


package com.androidhive.imagefromurl;

import java.io.InputStream;
import java.io.OutputStream;
public class Utils {
    public static void CopyStream(InputStream is, OutputStream os)
        final int buffer_size=1024;
            byte[] bytes=new byte[buffer_size];
              int count=is.read(bytes, 0, buffer_size);
              os.write(bytes, 0, count);
        catch(Exception ex){}
This image is for thumbnail purpose
android loading image from url
Hi there! I am Founder at androidhive and programming enthusiast. My skills includes Android, iOS, PHP, Ruby on Rails and lot more. If you have any idea that you would want me to develop? Let’s talk: ravi@androidhive.info
  • m.k.

    hello, thank you for tutorial. Unfortunately, it works for me only on emulator and when i install it on my phone, images won’t load. Why does this happen?

    • m.k.

      and I need to tell that i have 83 mb of free memory on SD card and 50 mb free internal memory

  • Ajay Kumar

    Can Someone help me how can i integrate progressbar in this code? please!

  • arjun kn

    realy thanks man… works fine…

  • David Dimalanta

    There is a problem with the ImageLoader class. You see, when I added the BitmapFactory.Options o2 under decodeFile(File f) method, I get an “Unreachable Code” error status. What should I do?

  • Smart guy

    no image will be show only loader image is shown help me whats the problem

  • David Dimalanta

    Raise the REQUIRED_SIZE.

  • David Dimalanta

    This tutorial is the worst! It is due by updates, instead of the image loaded properly from the URL, I got corrupted image as a result. Look at my sample.


  • Kimmi Dhingra

    hello..i have to load images & and data from webservices…can u plz help me….

    • this is what you want

      • waseem ahmad

        @pratik butani,,,,how to load info like(username ,intrest,gender ,,) in this code

  • subash

    u can use universal image loader library for that…………….

  • Dilip Panchal

    I want to display image in ListVIew From PHP Server or web server .
    But I need to set my Enulator HeapSize more than 32 MB. It Generate Errors.
    Can I Use Above Code to Display Image in List View From Server.
    Help Me.
    I am your website great FAN.


  • Fernando

    this tutorial is so good
    i read about a lib for developer games in android [libgdx]
    can you do tutorials about this?

  • jaradat

    i want to show image in large size so i replace _s by _n but it save it as small,as follow:
    String _n=_s.replace(“_s.jpg”, “_n.jpg”);
    imageLoader2.DisplayImage(_n, picture);

    plz could any one help me?

  • anonim

    break the json into pices until you get the url

    • waseem ahmad

      @anonim …..plzzzz explain how to code to get (username ,…gender,…etc) i m also using json webservic url ,,,,aftr login

  • Rajsekar

    Hi Ravi
    This tutorial is very helpful to me please post the dynamic grid view (Images from server) at least please give me a sugeestions

  • Poongkundran

    Please give me code to display multiple images from MYSQL DB with help of php webservice

    • DataBaseManager


  • Nirmal Revar

    hi did u got solution of that image blurred ,,,,

  • Khyati

    With the same code when i replace image url it throws FileNotFound Exception . i m stuck with it. Any idea?

    • avinash

      check permissions

      • Abhishek garg

        sir i have same problem
        and i have already add this permision

  • Chaitendra Pratap

    Thnaks this is very helpful..

  • Hi Ravi… Its Fantastic Tutorial.. Thanks a lot.

    Here I want to Update Image directly in My Folder, how can i update without passing ImageVIew object.

    i have tried like this:

    new ImageLoader(this).getBitmap(imagePath);

    It’s giving me Error…

    what can i do… Please Reply me…

  • Urvish Shah

    Hello sir i am getting too many redirects exception please help me out.

  • ishaque

    hi ravi …great tutorial ….thankz for this..

    then can you provide the API php code for how can i add image to my database and retrieve from it and send to my android app using json…..

  • Miguel

    Hi Ravi, I haven’t tried this yet, but I want to know if I can use this for populating listview with images? Thanks!

  • Guest

    Hi Ravi,
    How can i set size image from your project, image downloaded and show on device too small than this link: http://api.androidhive.info/images/sample.jpg
    Thanks so much

  • njzk2

    That would be nicer if you actually wrote this code.

  • Amit

    Hi, thanx for the good tutorial but i want to load multiple images ho to do that?

  • Vy.NLN

    Pls help me out!
    Why i use this link: http://www.deminit.com/images/wallpapers/med/female_models/sexy_cosplay_asian_girl/Sexy%20Cospl_26379_2005.jpg
    above sample can’t load image, return bitmap=null;

  • Udhay

    Reading image from URL can be performed inside AsynTask as it should not affect the current Activity. Using AysnTask will run downloading image from URL as separate thread.

  • Ashish Tiwari

    Hi, How to store the Images in internal memory of the phone? In this tutorial we are using External memory for cache

  • Dheeraj

    hi , The tutorial helped me a lot…

    I have one question though.. Where can I change the size of the image which is downloaded?

    Is it possible?


  • SBE

    did not works with images in a listview

  • guytrx

    GREAT TUTORIAL i use it to my app – its work perfect!:)
    i m asking your help guys
    i use my personal String url – JSON that i downloads about 500 images from my Json!
    when i scroll the list view fast i

  • Tom Bardsley

    hi. What is R.drawable.loader? I ask because my program does not recognize it

    • SSRI

      It is an image name exists in the drawable folder

  • Rajesh Narwal

    Its working but i am unable to understand this code. It would be lot better if you explain the working of this project.

    • SSRI


  • jayanti

    nice this is so good

  • Wilson

    Hi Ravi, where do i need to recycle the bitmap? im having trouble whenever i re-open my app using these codes. it says out of memory. thanks

  • Ej Castro

    Hi, may i know what is the R.drawable.loader. If it was a code/ image may i have it cause i dont have it on my drawable folder. Thanks in advance.

    • Ej Castro

      Got it, just an image.

  • Ej Castro

    Im using a fragment and this how i use it:

    ImageLoader imgLoader = new ImageLoader(getActivity().getApplicationContext());

    public void DisplayImage(String url, int loader, ImageView imageView)
    stub_id = loader;
    imageViews.put(imageView, url);
    Bitmap bitmap=memoryCache.get(url);
    queuePhoto(url, imageView);
    And im getting an error when i call the java class. What is the problem on my code?

    • Deepak

      only use

      ImageLoader imgLoader = new ImageLoader(getActivity() );

  • waseem ahmad

    hi ravi i want to know ….i want to set image in circle …i m using this code …..so whare to edit ..what to edit in code…..plzzzz rply fast

  • RedHood

    Very helpful, thanks

  • waseem ahmad

    i ravi i m using this code its working i have i query ….i want to display image in size as i want …….can u tell me how to increse/decrease size of image which is comming from url

  • waseem ahmad

    i ravi i m using this code its working i have i query ….i want to display image in size as i want …….can u tell me how to increse/decrease size of image which is comming from url….plzz reply fast

  • What if I want to make the extension of string image_url automatically detect whether .jpg or .png?
    // Image url
    String image_url = “http://api.androidhive.info/images/sample.jpg”; // or png?

  • elleray

    I’m confused with this function”boolean imageViewReused(PhotoToLoad photoToLoad)”,could you tell me what it is used for?

  • vahid

    thank you very much. Many useful posts :-*

  • suraj

    07-19 19:15:40.211: E/StrictMode(1106): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.

  • suraj

    07-19 19:15:25.171: E/StrictMode(1085): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.

    07-19 19:15:25.171: E/StrictMode(1085): java.lang.Throwable: Explicit termination method ‘end’ not called

    07-19 19:15:25.171: E/StrictMode(1085): at dalvik.system.CloseGuard.open(CloseGuard.java:184)

    07-19 19:15:25.171: E/StrictMode(1085): at java.util.zip.Inflater.(Inflater.java:82)

    07-19 19:15:25.171: E/StrictMode(1085): at java.util.zip.GZIPInputStream.(GZIPInputStream.java:96)

    07-19 19:15:25.171: E/StrictMode(1085): at java.util.zip.GZIPInputStream.(GZIPInputStream.java:81)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.okhttp.internal.http.HttpEngine.initContentStream(HttpEngine.java:610)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:856)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:143)

    07-19 19:15:25.171: E/StrictMode(1085): at java.net.URLConnection.getContentType(URLConnection.java:326)

    07-19 19:15:25.171: E/StrictMode(1085): at java.net.URLConnection.getContent(URLConnection.java:193)

    07-19 19:15:25.171: E/StrictMode(1085): at java.net.URL.getContent(URL.java:455)

    07-19 19:15:25.171: E/StrictMode(1085): at com.example.marico.LibaryClass.loadImageFromWeb(LibaryClass.java:661)

    07-19 19:15:25.171: E/StrictMode(1085): at com.example.marico.LibaryClass.onCreate(LibaryClass.java:251)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.Activity.performCreate(Activity.java:5426)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.ActivityThread.access$900(ActivityThread.java:161)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)

    07-19 19:15:25.171: E/StrictMode(1085): at android.os.Handler.dispatchMessage(Handler.java:102)

    07-19 19:15:25.171: E/StrictMode(1085): at android.os.Looper.loop(Looper.java:157)

    07-19 19:15:25.171: E/StrictMode(1085): at android.app.ActivityThread.main(ActivityThread.java:5356)

    07-19 19:15:25.171: E/StrictMode(1085): at java.lang.reflect.Method.invokeNative(Native Method)

    07-19 19:15:25.171: E/StrictMode(1085): at java.lang.reflect.Method.invoke(Method.java:515)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)

    07-19 19:15:25.171: E/StrictMode(1085): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)

    07-19 19:15:25.171: E/StrictMode(1085): at dalvik.system.NativeStart.main(Native Method)

  • dhiraj choudhary

    hi, ravi your tutorials are superb but how could i increase the size of cache for bigger image files or higher resolution bitmaps

  • Anshul Goyal

    I also wanted to load images from android phone(internal and external storage) but this image loader download image from http request. How may do it with using internal and external storage.

  • Wahib

    Hi, I followed this tutorial for my app. I populate a listview from an api. Each item of my listview has an image.
    After loading a certain amount of image i encounter a
    java.lang.OutOfMemoryError: pthread_create (stack size 16384 bytes) failed: Try again

    How can I avoid that?

    Thanks in advance.

  • Er B S Choudhary

    lot of thanks to androidhive.info….

  • abhi Gavade

    how to send image and text through notification for multiple device

  • erfan

    how can get image bitmap from loader ? i need bitmap so i can show on circle image view
    is there any way to get bit map?

  • Amit Gupta

    Thanks a lot androidhive.

  • DomenicoButtafarro

    hi friend , i have need share whit intent the bitmap, can help me? thanks

  • Tõp Bęãrd.


  • kopilatis

    I love you dude

  • SK

    How to do the same if the image source is “https://……” instead of “http://….” ?

  • kiran

    does this works fine in the fragments because iam getting null pointer exception need answer imediately


    What is int loader = R.drawable.loader; ?

    • MAQAH

      Got it , it’s just an image. But why , whats the use ?

      • PulkitTyagi

        Place holder until the required image is loaded .

        • MAQAH

          Oh . Thanx.


    Got an error : Attempt to invoke virtual method ‘void android.widget.ImageView.setImageResource(int)’ on a null object reference

    • chemechaos

      I had a similar problem. The imageview id in your layout file isn’t matching with the declaration in your activity, or you shouldn’t put int but loader inside setImageResource,

  • chemechaos

    Because I needed to reload the image every time my app loaded, I added clearCache(); before queuePhoto(url, imageView);

  • Anish Panthi

    The pictures that I extracted from the given URL is not perfect as it is. All images are blur. How can I display the exact picture quality?

    • Anish Panthi

      modified decodeFile(File f) and is now working fine with original image quality. Thankyou Ravi Ji for this great turotial.

      • Salam Badareen

        have same problem too … pls can u tell me the modification if you can
        Thnx in advance 😀

        • Salam Badareen

          increase the required size

          • ViciousFox

            Thank you 😮

        • Anish Panthi

          Sorry for the late reply. use the following code:

          private Bitmap decodeFile(File f) {
          try {
          // //decode with inSampleSize
          BitmapFactory.Options o2 = new BitmapFactory.Options();
          // o2.inSampleSize=scale;
          return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
          } catch (FileNotFoundException e) {
          return null;

          • Navdeep Agrawal

            Thank Anish 🙂

            and yes thanks Ravi

  • Gilang Surahman

    show on emulator but not show on real device? why?

  • Varun Dagur

    hi sir can you please tell me how to download image in its actual size

  • Sudarshan

    will everytime load image from url? Or second time it will load from card?

  • Bhavik Shah

    Hello Ravi,

    I want to cover the Whole Screen for Images and Height Should be Increased? How can I do it?

  • nagaraju bhimavarapu

    how to set the top index image of list view as image view under the tab layout
    please help me

  • Emre Can ÖZKÖK

    omg Its worked first launch. many many thank

  • Sahil Huseynzade

    Thanks Ravi , very helpful

  • Hit Man

    how i can create movie app using android ……….. i’m a Beginner

    • Learn android very well. Then you can think about building your Movie app 🙂

      • Hit Man

        Could you help me Please step by step in this …. And recommend to me a good tutorials to learn Android very well ?


    Loading image is showing but not set Image url on this image

  • Yatish Dua

    java.io.FileNotFoundException: /storage/emulated/0/TempImages/-1927115832: open failed: ENOENT (No such file or directory)

    • Bikalpa Kattel

      same here.. did u find the solution for that?

      • stephane lillo

        If you use android 6 or higher the permission system changed. You need to manually asked the user the WRITE_EXTERNAL_STORAGE permission.

  • Satria Winarah

    Great!! Thank so much..!!

  • Kate Hwang

    This posting helps me a lot. It works!!
    I just want to say Thank U!

  • Kaushal Kishor

    Dear Ravi thanks for the great job which you are doing for us……..can you please post me how to populate this image in RoundedImageView…..emailID : kaushalkishor76@gmail.com

  • Matthew

    Dear Ravi, If I want to load two images, which are come from different urls, to two different imageview, how can I complete this task? Please help!

  • hussein kalash

    thank you that was helpfull

  • Mayura Devani

    Two Problems:
    1. Sometimes half Bitmap is loading in imageview
    2. Duplicate URL fetch image from cache, new image won’t be displayed.

  • Eggy Sudianto

    how to call the function in mainActivity? example please

  • medozeus

    its didnt load new image i just show loader image what the problem the url string its right and i add all permission

    • medozeus

      if any body have same problem contact me in facebook
      fb.com/deluxezeus998 i solve it

  • medozeus

    if any body use this code in none activity and image not shown follow this steps

    remove this two line in ImageLoader.java
    1- Activity a=(Activity)photoToLoad.imageView.getContext();

    and use this code

    2-new Handler(Looper.getMainLooper()).post(bd);

    • Jose

      That was great man thank you!!

    • Putra Nugraha


  • medozeus

    wtf deleted my comment why ? its will help reader suck site

  • Richardson. M

    Good, Thanks for sharing the code.

    How to show preloaded text before loading image?

  • manoj kumar

    Hi bro,
    Does this work with pdf url

  • Shruity

    I have implemented this code and taken the image url from json through web service but the image is not displaying.

  • Shikhar Shah

    please help me out. Image from any url not getting loaded and only loader is shown .

  • Yash Agrawal

    @ravi8x:disqus sir if we want to show progress in notification while downloading the image , I am unable to put it properly as either i am getting no notification or at improper time ! Looking forward to your help ! Thank you !.

  • Great ! THank you

  • Bhavesh Sharma

    Hello Sir can yo help me How to Retrieve image in recycler view from database using json ?

  • Islahudin Mly

    how to call an image that has been downloaded and entered into the cache to drawable

    • Use the libraries like Volley, Glide, Picaso or Fresco.


    is it possible to send image from server to android using json??
    image stored in particular folder and its name stored in mysql database .use php for server side scripting

  • Manik Soni

    imageView.setImageResource ….try to invoke virtual method on a null object reference …
    Struggled alot
    my logcat
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.widget.ImageView.setImageResource(int)’ on a null object reference
    at manik.vnrvjietcse.ImageLoader.DisplayImage(ImageLoader.java:50)
    at manik.vnrvjietcse.Activity1.onCreate(Activity1.java:39)
    at android.app.Activity.performCreate(Activity.java:6679)

    Please help!!

    • Kamran Ahmed Ansari

      The reference of the ImageView you passed into the ImageLoader class points to null. In simple words, check your findViewById(R.id.image) part of the code. It must be returning null.

  • saravanan.a kumar

    sir i need ‘n’ number of image url how to load all image using image loader

    • manoj gundapaneni

      Keep all images in code..thn generate url….use Gson and glide


    i search image in internet and set into image view how can i save this image into my phone storage /sd card???

  • anil thakor

    Hi Sir I have Problem is that if i change image on firebase through direct or other one upload his new image then when i load this image than its show old image and get from catch memory so please tell me how to notify to catch if i change image on firebase is it because of replace image ? How can i identifie that image is exist on firebase storage or not?

  • Nishant Makwana

    hello sir how can i get image from phpmyadmin and set imageview pls help me

  • Manisha Khatke

    image is not showing in android 6 and above version??

  • Ajay Saini

    how to improve image quality,

  • Adithya L

    I have got ‘out of memory’ exception while loading the image… Could you plz solve this issue?

    • manoj gundapaneni

      hav you added permission in manifest files

  • Ziya khan

    Did you code all this by yourself ? Or took sample code and then modified ?

  • dabhi dhvani

    how to api image data set in galleryview in android???please help

  • Ketan

    i used the same code , But i had problem when I give multiple calls simultaneously (in my case I give 10 calls to download 10 images ) the run() method in ImageLoader was called multiple times but the getBitmap wasn’t called same number of times . Only 2 to 3 times getBitmap was called … How to overcome that problem

  • Harsha

    Unbelievably large amount of code to load a simple image!

  • TeamB58

    I need to set an image that is loaded from a url as background of my layout. I tried a number of codes available online. None worked.(Getting networkonmainthread exception). Will be happy if you can guide me.

    Thank you.

  • Derick Kabwe

    Hi thank you for the webview android tutorial, but how do you load a local file to display an error if device has no internet or the address is unreachable?

  • Muhammad Faashan

    Bro i NEED a solution, I need to connect with hosted server to access my database

  • Saravanan Chinnadurai

    Hi Ravi,
    I am getting URL lists for images. How do i set those images to recycler view. My doubt is how to get multiple images in a single request

  • Abhradeep Ghosh

    while calling imgLoader.DisplayImage from the adapter,
    Bitmap bitmap = memoryCache.get(url) inside the DisplayMessage method ; // bitmap is giving null here .
    Any help would be appreciated.

  • App AlgoFácil

    Hello Ravi, no cosegui downloads the image. Ne, I know to change to display the image actually, You can give me an orientation? I’m young in programming.

  • Sudeer

    Hi Ravi, thanks for your tutorial I like to know how we can capture an image and send the image URL to backend and receive the input in JSON can you help in this

  • Sudeer

    an hour ago
    Thank you for your reply but I wanna send image in an URL format can you help me bro

  • amit pandya (tattoo hunter)

    Hi Ravi sir, How can I work with this ImageLoader when I am offline? Can you please revert back on my question?