Android - How to Load Image by name using Glide
Use Uri.
String image = "image.jpg";
String completePath = Environment.getExternalStorageDirectory() + "/" + image;
File file = new File(completePath);
Uri uri = Uri.fromFile(file);
Glide.with(this).load(uri).into(imageView);
Call getImage
method for get Drawable
using Name only.
Glide.with(this).load(getImage(my_drawable_image_name)).into(myImageView);
public int getImage(String imageName) {
int drawableResourceId = this.getResources().getIdentifier(imageName, "drawable", this.getPackageName());
return drawableResourceId;
}
Try this:
Glide.with(this)
.load(getResources()
.getIdentifier("my_drawable_image_name", "drawable", this.getPackageName())
.into(myImageView);