Load image from URL in android using Glide

Hey friends, in this post, we will see how to load image from URL in android using Glide library. Glide is an image loading library which can be used to load an image to the imageview, from an URL. After loading the image from the URL, it basically stores that image loaded, in a cache which can be later viewed when there is no internet connection.

This post is divided into 4 parts

  1. Adding the Glide Library to your project
  2. Registering an imageview object with glide
  3. Loading image into the imageview object with Glide (Internet Connection)
  4. Loading image into the imageview object (No Internet Connection)
Why loadĀ image from URL in android using Glide?
  • Fast and efficient open source library for image loading and disk caching.
  • Simple and easy to use interface
Fetch image from URL in android using Glide
Output at the end of the post

Step1 – Adding Glide Library to your project

Go to app level Gradle, from your android studio, in your project and then add the below line.

Now go to manifest, and then give the internet permissions

Step2- Registering Imageview object with Glide

Glide functions:

  • load() – Here you can specify the URL String
  • placeholder() – You can specify the loading image
  • error() – You can specify the image when URL fails to load
  • into() – Here you need to specify the target ImageView.

Now install the application in your android, turn on the internet and you can see the image gets loaded. Next time when you reopen, the same app, you don’t need any internet connection because, the image has already been stored in the cache.

Hey there, I’m Sid. I often write articles here. Apart from being a developer, my interest range from blogging, designing, tinkering and hearing electronic. To connect with me, just navigate to any social icons, below!

Sidharth Patnaik

Hey there, I'm Sid. I often write articles here. Apart from being a developer, my interest range from blogging, designing, tinkering and hearing electronic. To connect with me, just navigate to any social icons, below!

Leave a Reply

Your email address will not be published. Required fields are marked *