Using Glide for Android, how do I load images from asset and resources?

Glide
.with(context)
.load(uri)
.asBitmap()
.placeholder(R.drawable.yourimage)
.error(R.drawable.yourimage)
.into(yourview);

Apart from the above answer if the image URL return null you can load default image into the view as like above.


For resource ids, you can use:

Glide.with(fragment)
    .load(R.drawable.resource_id)
    .into(imageView);

For assets, you can construct an asset uri:

Glide.with(fragment)
    .load(Uri.parse("file:///android_asset/<assetName>"))
    .into(imageView);