title: Getting exception while opening PDF file for Android 26 using Firemonkey/Delphi
body: <p>I'm using Delphi 10.1 Berlin for developing Android mobile application and I need to open the PDF file from the application but I'm getting the error - <strong>android.os.FileUriExposedException: file:///Storage/emulated/0/Download/AppDataDetails/1.Pdf exposed beyond app through Intent.getData()</strong> and below I have mentioned the code:</p>
  
  <p>AndroidManifest.template.xml:</p>
  
  <pre><code>&lt;!-- **** ADD THIS SECTION **** --&gt;
  &lt;provider
      android:name="android.support.v4.content.FileProvider"
      android:authorities="com.AatchiyarIAS.fileprovider"
      android:exported="false"
      android:grantUriPermissions="true"&gt;
      &lt;meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/&gt;
  &lt;/provider&gt;
  </code></pre>
  
  <p>provider_paths.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
    &lt;external-path name="external_files" path="."/&gt;
  &lt;/paths&gt;
  </code></pre>
  
  <p>Delphi Code:</p>
  
  <pre><code>function TFrameFileDetail.GetMimeType(Uri: Jnet_Uri): JString;
  var
    MimeType: JString;
    ContentResolver: JContentResolver;
    FileExtension: JString;
  begin
    // https://stackoverflow.com/a/31691791/2899073
  
    MimeType := nil;
    if (Uri.getScheme.equals(TJContentResolver.JavaClass.SCHEME_CONTENT)) then
    begin
      ContentResolver := TAndroidHelper.Context.getContentResolver();
      MimeType := ContentResolver.getType(uri);
    end
    else
    begin
      FileExtension := TJMimeTypeMap.JavaClass.getFileExtensionFromUrl(uri.toString());
  
      MimeType := TJMimeTypeMap.JavaClass.getSingleton().getMimeTypeFromExtension(
        fileExtension.toLowerCase()
      );
    end;
  
    Result := MimeType;
  end;
  
  
  procedure TFrameFileDetail.OpenPDF(InpStrPDFPath: string);
  var
    Data: Jnet_Uri;
    Intent: JIntent;
    javafile: JFile;
    &amp;OriginalFile, PublicDirectoryFile, PublicFile: JFile;
    PublicDirectoryPath, PublicPath: string;
    Uri: Jnet_Uri;
  begin
    PublicFile := TJFile.JavaClass.init(StringToJString(InpStrPDFPath));
    Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_VIEW);
    Uri := TJnet_Uri.JavaClass.fromFile(PublicFile);
    Intent.setDataAndType(Uri, self.GetMimeType(Uri));
    Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NO_HISTORY);
    TAndroidHelper.Activity.startActivity(Intent);
  end;
  </code></pre>
  
  <p>Please help me to fix this issue. </p>