title: Android open downloaded file
body: <p>I have a question about downloading a pdf file and opening it with an pdf reader application installed on the phone. I'm new to android and working my way up but got stuck on this part.</p>
  
  <p>So what i have now:
  I have an activity that for now starts downloading a pdf file and tries to open is with an intent. For now everything is static so thats why i have a set url.</p>
  
  <pre><code>private void DownloadFile(){
          DownloadManager downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
          Uri Download_Uri = Uri.parse("http://awebiste.adomain/afile.pdf");
          DownloadManager.Request request = new DownloadManager.Request(Download_Uri);
  
          request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);    
          request.setAllowedOverRoaming(false);   
          request.setTitle("My Data Download");
          request.setDescription("Android Data download using DownloadManager.");
          request.setDestinationInExternalFilesDir(this,Environment.DIRECTORY_DOWNLOADS,"test.pdf");
  
          Long downloadReference = downloadManager.enqueue(request);
  
          if (downloadReference != null){
              Intent target = new Intent(Intent.ACTION_VIEW);
              target.setDataAndType(Uri.parse(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + "/test.pdf"), "application/pdf");
              target.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  
              Log.v("OPEN_FILE_PATH", getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) + "/test.pdf");
  
              startActivity(target);
  
          } else {
              //TODO something went wrong error
          }
      }
  </code></pre>
  
  <p>Now the file is downloaded and saved in the application folder under <code>/storage.sdcard0/Android/data/&lt;application&gt;/files/download</code> and from the documents browser the file can be opent. But when i use the intent at the button of my code i get a toast that the file can not be opent. After some searching on google i think its a permission problem because these files are private to the application. So how do I make these files public? </p>