title: Download music file using DownloadManager auto-delete after 7-9 days android 11
body: <p>I am downloading music using DownloadManager and store in &quot;<strong>MUSIC</strong> directory in android 11, After some times 7-9 days, the music file will auto-delete from location.</p>
  <pre><code>DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
  request.setTitle(downloadBookBean.getBookName() + &quot; &quot; + chapter_1);
  if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
      request.allowScanningByMediaScanner();
      request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
  }
  
  try {
                  if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.Q)
                      request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MUSIC,
                              mContext.getApplicationInfo().loadLabel(
                                      mContext.getPackageManager()) + &quot;/audio/&quot; + fileName);
                  else
                      request.setDestinationUri(Uri.fromFile(new File(Environment.getExternalStorageDirectory() +
                              File.separator + Utility.DOWNLOAD_MAIN_FOLDER_NAME + File.separator + &quot;Audio Files&quot;, fileName)));
              } catch (Exception e) {
                  return;
              }
  </code></pre>