作者:沸腾的热水_948 | 来源:互联网 | 2023-01-28 20:30
我有一个Activity
在其中下载图像的zip文件然后解压缩getFilesDir()
.路径是这样的:
/data/user/0/packagename/files/files/example.png
但是,当我尝试加载这些图像时,它们没有显示.我正在使用此代码获取路径并加载图像:
String loc = getFilesDir().getPath() + "/" + Config.IMAGES_LOCATION +"/";
String imageloc = loc + model.getThumbnail();
Glide.with(ActivityImageGallery.this).load(imageloc).into(image);
imageloc路径与保存位置相同,并且从路径创建文件时,它显示它将存在.
我尝试file://
在路径前使用,但这也不起作用.WRITE_EXTERNAL
en READ_EXTERNAL
权限被询问并被授予.
1> Zeeshan Shab..:
这适用于我,制作文件实例并传递要加载的文件的uri ImageView
Glide.with(context)
.load(new File(fileUri.getPath())) // Uri of the picture
.into(profileAvatar);
确保你已添加
您还可以RequestListener
用于在发生故障时跟踪错误
new RequestListener() {
@Override
public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
我希望这能帮到您.