title: ACTION_VIEW and FileProvider - how to open html file from sdcard in browser
body: <p>I could not find a smart solution to my problem and that is why I decided to write to you good people. I have a question for your regarding FileProvider and ACTION_VIEW, namely, I save the html file this way:</p>
  <pre><code>    File sdcard = getBaseContext().getExternalFilesDir(null);
      File dir = new File(sdcard.getAbsolutePath() + “/MYDIR/“);
      dir.mkdir();
      File file = new File(dir, “MYFILE.html&quot;);
      File recordFile = new File(sdcard.getAbsolutePath()+ &quot;/MYDIR/&quot; + &quot;MYFILE.html&quot;);
      FileOutputStream os = null;
      try {
          os = new FileOutputStream(file);
          os.write(returnedText.getText().toString().getBytes());
          os.close();
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  <p>its path: <code>storage/emulated/0/Android/data/com.myapp/files/MYDIR/MYFILE.html</code></p>
  <p>This is how I call my html file:</p>
  <pre><code>File sdcard = getBaseContext().getExternalFilesDir(null);
  Intent intent = new Intent(Intent.ACTION_VIEW);
  File f = new File(sdcard.getAbsolutePath() + &quot;/MYDIR&quot; + &quot;/MYFILE.html&quot;);
  intent.setDataAndType(Uri.fromFile(f), &quot;text/html&quot;);
  intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION|
          Intent.FLAG_ACTIVITY_NO_HISTORY|
          Intent.FLAG_ACTIVITY_NEW_TASK);
  Intent.createChooser(intent, &quot;File Browser&quot;);
  startActivity(intent);
  </code></pre>
  <p>I want to call this <code>MYFILE.html</code> via <code>Intent</code> and open in <strong>HTML Viewer</strong>, I get this error:</p>
  <p><code>ERR_ACCESS_DENIED</code></p>
  <p>So I decided to try FileProvider, but I get a completely different path. What should I do, any specific idea??? Thanks in advance.</p>
  <p>My FileProvider:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;paths xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
  &lt;external-path
      name=&quot;external_files&quot;
      path=&quot;.&quot; /&gt;
  &lt;/paths&gt;
  
      &lt;provider
          android:name=&quot;androidx.core.content.FileProvider&quot;
          android:authorities=&quot;com.myapp.provider&quot;
          android:exported=&quot;false&quot;
          android:grantUriPermissions=&quot;true&quot;&gt;
          &lt;meta-data
              android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot;
              android:resource=&quot;@xml/provider_paths&quot; /&gt;
      &lt;/provider&gt;
  </code></pre>