title: How to get original file name while downloading file with DownloadManager?
body: <p>I´ve an app, in which user can download files. For the download-process i use androids <code>DownloadManager</code> class. The file-download works perfectly, but i want to achieve, to store the file using the orginal file name of the downloaded file from the internet url. I´ve searched in the web and found different methods. The most just try to parse to file name from the url like so:</p>
  
  <blockquote>
    <p>URL: https:// mysite.com/ filename.txt </p>
    
    <p>parse the file name with <code>url.substring(url.lastIndexOf('/') + 1)</code> an you will have your file name...</p>
  </blockquote>
  
  <p>But i need a method, that gets the file name also, if the file name is not included clearly in the url.</p>
  
  <p>I also found some method to get the file name with</p>
  
  <pre><code>URLUtil.guessFileName(url, contentDisposition, mimetype)
  </code></pre>
  
  <p>I´ve implemented this method, but i´am getting always "download.bin" as my file name , which is incorrect. Maybe i have incorrect contentDisposition or mimetype for this method. How do you create contentDisposition or mimetype from just an url?</p>
  
  <p>So i´m a bit helpless with this. Is there a safe working method with this.</p>