I have an Activity
in which I download a zipfile of images and then unzip in the getFilesDir()
. Path is like this :
/data/user/0/packagename/files/files/example.png
When I try to load these images however, they're not showing. I'm using this code to get the path and load the image:
String loc = getFilesDir().getPath() + "/" + Config.IMAGES_LOCATION +"/";
String imageloc = loc + model.getThumbnail();
Glide.with(ActivityImageGallery.this).load(imageloc).into(image);
The imageloc path is the same as the save location and when creating a file from the path, it shows that it would exist.
I tried using file://
in front of the path, but that doesn't work either. WRITE_EXTERNAL
en READ_EXTERNAL
permissions are asked and granted.
This works for me, make file instance and pass file's uri that you want to load into ImageView
Glide.with(context)
.load(new File(fileUri.getPath())) // Uri of the picture
.into(profileAvatar);
Make sure you have added
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
You can also use RequestListener
to trace the error in case of failure
new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}