Home > Software engineering >  How to load image from URL that is in database
How to load image from URL that is in database

Time:05-26

How can I load an image using a URL that is saved in a database and display it in a Recycler View in an Image View

I have a database that displays data as an output in my app but I cant figure out how to make the URL for an image in the database load as an image.

CodePudding user response:

you can load an image from URL by using glide:

first

implementation 'com.github.bumptech.glide:glide:4.11.0'

        Glide
        .with(context)
        .load("URL placed here")
        .centerCrop()
        .placeholder(R.drawable.animation_color_grad)
        .into(holder.img_app_icon)

CodePudding user response:

There are multiple options available to load an image from URL.

You can use Picasso like this:

Picasso.get().load("your_url").into(imageView);

Also you can use Glide (Faster than Picasso)

Glide.with(this).load("your_url").into(imageView);

Or you can convert your URL to Bitmap and then set it into ImageView without using any library. See this for this approach: How to get bitmap from a url in android

  • Related