使用 glide 清理 Firebase 缓存

Clean Firebase cache using glide

好吧,我使用 firebase 来存储与用户个人资料相关的图像,目前确实发生了一些奇怪的事情,我的可绘制对象中有一个默认图像,每次我的 firebase 存储引用为空时,它都会显示在图像视图中,否则它会使用 glide 来显示图像,但我删除了我在 firebase 的所有存储,它仍然显示我在数据库中的图像,为什么会这样?这与 phone 上的 localStorage 相关吗?我怎样才能删除它?

    storageRef = storage.getReferenceFromUrl("gs://friendlymanager-3b7a2.appspot.com/Photos/" + userId);


Uri path = Uri.parse("android.resource://com.esmad.pdm.friendlymanager/" + R.drawable.defaultuserimage);
Log.d("image2",storageRef + "/Photos/" + userId + ".jpg");
if(storageRef != null){
    Glide.with(this)
            .using(new FirebaseImageLoader())
            .load(storageRef)
            .error(R.drawable.defaultuserimage)
            .into(userImage);
}
else{
    userImage.setBackgroundResource(R.drawable.defaultuserimage);
}

尝试禁用磁盘和内存缓存:

    Glide.with(this)
            .using(new FirebaseImageLoader())
            .load(storageRef)
            .diskCacheStrategy(DiskCacheStrategy.NONE) // <= ADDED
            .skipMemoryCache(true) // <= ADDED
            .error(R.drawable.defaultuserimage)
            .into(userImage);

已添加:

测试 storageRef 是否为 null 不能用于确定数据是否存储在该位置。您只能通过尝试加载数据或其元数据来确定某个位置是否存在数据。