title: How to open file from internal storage in specific viewer?
body: <p>I want to open File which is in <code>InternalStorage</code></p>
  
  <p>I created <strong>Documents</strong> directory under <strong>data/data/mypackage/files</strong> path .</p>
  
  <p>Now I want to <strong>Open a file in some external application like PDF viewer or text viewer.</strong></p>
  
  <p>I already checked, the file exists but when I am opening file in specific viewer like PDF viewer, </p>
  
  <p>it display Toast-  <strong>"Can not display PDF"</strong>.</p>
  
  <p>I am using below code to open file in the specific viewer.</p>
  
  <pre><code>File file=new File(context.getFilesDir()+"/Documents/"+fileInfo.getFilename()+"."+fileInfo.getFiletype());
  if (file.exists()){
      Uri uri = Uri.parse("file://"+file);
      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setDataAndType(uri, "application/pdf");
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
      context.startActivity(intent);
  }
  </code></pre>
  
  <p>Chooser will open for select PDF viewer.</p>
  
  <blockquote>
    <p>How to Open PDF or Text File from internal Storage
    (data/data/com..somepackagename/files)?</p>
  </blockquote>