title: Unable to download Image through url into my phone in android 10
body: <p>I m trying to download image into phone storage through its url using glide its working fine in android 9 or below buts its not working in case of android 10,</p>
  <p>Here is my adapter code  where i added download funtion, can some One help with the code</p>
  <p>public class Adapter extends RecyclerView.Adapter&lt;Adapter.ViewHolder&gt; {</p>
  <pre><code>Context context;
   ArrayList&lt;Model&gt; modelArrayList;
  
  public Adapter(Context context, ArrayList&lt;Model&gt; modelArrayList) {
      this.context = context;
      this.modelArrayList = modelArrayList;
  }
  
  @NonNull
  @Override
  public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  
      View view = LayoutInflater.from(context).inflate(R.layout.item_layout, parent,false);
  
      return new ViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
  
      String url = modelArrayList.get(position).getUrl();
        holder.setImage(url);
        holder.button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent sharing = new Intent (Intent.ACTION_SEND);
                sharing.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                sharing.setType(&quot;text/plain&quot;);
                String subject = &quot;Hey Man just look at this coll meme click the link &quot; +url;
                sharing.putExtra(Intent.EXTRA_TEXT,subject);
                context.startActivity(Intent.createChooser(sharing,&quot;Shring using&quot;));
            }
        });
  
        holder.buttonDownload.setOnClickListener(new View.OnClickListener() {
            @Override
  
  
            public void onClick(View view) {
  
                    
                      downloadImage(url);
            }
        });
  
  }
  
  @Override
  public int getItemCount() {
      return modelArrayList.size();
  }
  
  public class  ViewHolder extends RecyclerView.ViewHolder{
  
      ImageView imageView;
      Button button,buttonDownload;
  
      public ViewHolder(@NonNull View itemView) {
          super(itemView);
  
          imageView = itemView.findViewById(R.id.imageView);
          button = itemView.findViewById(R.id.button);
          buttonDownload = itemView.findViewById(R.id.btn_download);
      }
  
      void setImage(String link){
          Glide.with(context).load(link).into(imageView);
      }
  }
  
       void downloadImage(String imageURL){
  
       String dirPath = Environment.getExternalStorageDirectory().getAbsolutePath() + &quot;/&quot; + &quot;memebook&quot; + &quot;/&quot;;
       final File dir = new File(dirPath);
       final String fileName = imageURL.substring(imageURL.lastIndexOf('/') + 1);
       Glide.with(context)
                   .load(imageURL)
                   .into(new CustomTarget&lt;Drawable&gt;() {
                       @Override
                       public void onResourceReady(@NonNull Drawable resource, @Nullable Transition&lt;? super Drawable&gt; transition) {
  
                           Bitmap bitmap = ((BitmapDrawable)resource).getBitmap();
                           Toast.makeText(context, &quot;Saving Image...&quot;, Toast.LENGTH_SHORT).show();
                           saveImage(bitmap, dir, fileName);
                       }
  
                       @Override
                       public void onLoadCleared(@Nullable Drawable placeholder) {
  
                       }
  
                       @Override
                       public void onLoadFailed(@Nullable Drawable errorDrawable) {
                           super.onLoadFailed(errorDrawable);
  
                           Toast.makeText(context, &quot;Failed to Download Image! Please try again later.&quot;, Toast.LENGTH_SHORT).show();
                       }
                   });
  
       }
  
  
  private void saveImage(Bitmap image, File storageDir, String imageFileName) {
  
      boolean successDirCreated = false;
      if (!storageDir.exists()) {
          successDirCreated = storageDir.mkdir();
      }
  
      successDirCreated = true;
      if (successDirCreated) {
          File imageFile = new File(storageDir, imageFileName);
          String savedImagePath = imageFile.getAbsolutePath();
          try {
              OutputStream fOut = new FileOutputStream(imageFile);
              image.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
              fOut.close();
              Toast.makeText(context, &quot;Image Saved!&quot;, Toast.LENGTH_SHORT).show();
          } catch (Exception e) {
              Toast.makeText(context, &quot;Error while saving image!&quot;, Toast.LENGTH_SHORT).show();
              e.printStackTrace();
          }
  
      }else{
          Toast.makeText(context, &quot;Error&quot;, Toast.LENGTH_SHORT).show();
      }
  }
  </code></pre>
  <p>}</p>