title: How to download gif images from url and save to storage in android
body: <p>I want to add feature in my app to download a GIF Image from url to my phones storage.
  How can I do this into my application </p>
  
  <pre class="lang-java prettyprint-override"><code>public class Download {
  
      Context context;
      String url;
      ProgressDialog progressDailog;
  
      public void saveImage(Context context, String url) {
  
          this.context = context;
          this.url = url;
  
          progressDailog = new ProgressDialog(context);
          progressDailog.setMax(100);
          progressDailog.setMessage("Please wait...");
          progressDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
          progressDailog.setCanceledOnTouchOutside(false);
          progressDailog.show();
  
  
          Glide.with(context).asBitmap()
                  .load(url)
                  .apply(new RequestOptions()
                          .diskCacheStrategyOf(DiskCacheStrategy.ALL)
                          .format(DecodeFormat.PREFER_ARGB_8888)
                          .override(Target.SIZE_ORIGINAL))
                  .into(new SimpleTarget&lt;Bitmap&gt;() {
                      @Override
                      public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition&lt;? super Bitmap&gt; transition) {
                          progressDailog.dismiss();
                          storeImage(resource);
                          //Log.d(TAG, "Image : " + resource);
                      }
                  });
      }
  
      private void storeImage(Bitmap image) {
          File pictureFile = getOutputMediaFile();
          if (pictureFile == null) {
              return;
          }
          try {
              FileOutputStream fos = new FileOutputStream(pictureFile);
              image.compress(Bitmap.CompressFormat.PNG, 100, fos);
              fos.close();
              Toast.makeText(context, "Image Downloaded", Toast.LENGTH_SHORT).show();
          } catch (FileNotFoundException e) {
          } catch (IOException e) {
          }
      }
  
      private File getOutputMediaFile() {
          File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Christmas"); /*getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Christmas/c");*/
          if (!mediaStorageDir.exists()) {
              if (!mediaStorageDir.mkdirs())
                  return null;
          }
  
          File mediaFile;
          mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_MERRY_CHRISTMAS.jpg");
          return mediaFile;
      }
  
  }
  </code></pre>
  
  <p>From this code I can download the normal Image but it did not works on GIF. The GIF image downloaded and it remains static</p>