Try using an image library that can handle image caching.
You can try Glide or Picasso .
First add the library to your project. Instead of downloading the file and decrypting it yourself, use the library to download and cache the object for you.
(Glide example) After searching for the object and extracting the parsefile, use Glide:
ParseFile fileObject = (ParseFile) object.get("imageContent"); String url = fileObject.getUrl(); ImageView image = (ImageView) findViewById(R.id.image); Glide.with(getContext()) .load(url) .into(image);
The next time you open the application, Glide will search for the object in the cache and, if necessary, retrieve it.
source share