title: Download PDF for SDK < 29
body: <p>I'm developing an Android App, and I have the following problem.</p>
  <p>I want to download a PDF so I have this code:</p>
  <pre><code>        ContentResolver resolver = getContext().getContentResolver();
  
  if (Build.VERSION.SDK_INT &gt;= 29) {
              this.uri = resolver.insert(MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY), contentValues);
          } else {
              this.uri = resolver.insert(Uri.parse(&quot;\&quot;content://download\&quot;&quot;), contentValues);
  
      }
  </code></pre>
  <p>Here is the code where I download the PDF and try to open with intent.</p>
  <pre><code>FileOutputStream fos = new FileOutputStream(getContext().getContentResolver().openFileDescriptor(uri, &quot;rw&quot;).getFileDescriptor());
                              fos.write(responseBody);
                              fos.flush();
                              fos.close();
                              Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                              intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                              startActivity(intent);
  </code></pre>
  <p>When I use a mobile with SDK &lt; 29 it breaks down the app.</p>
  <p>This is my manifest.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  package=&quot;app&quot;&gt;
  &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;&gt;&lt;/uses-permission&gt;
  &lt;uses-permission android:name=&quot;android.permission.USE_BIOMETRIC&quot;/&gt;
  &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;
  &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
  &lt;uses-permission android:name=&quot;android.permission.ACCESS_BACKGROUND_LOCATION&quot; /&gt;
  
  &lt;queries&gt;
      &lt;intent&gt;
          &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;
          &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
          &lt;data android:scheme=&quot;https&quot; /&gt;
      &lt;/intent&gt;
  &lt;/queries&gt;
  
  
  &lt;application
      android:allowBackup=&quot;true&quot;
      android:icon=&quot;@mipmap/ic_launcher&quot;
      android:label=&quot;@string/app_name&quot;
      android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
      android:supportsRtl=&quot;true&quot;
      android:networkSecurityConfig=&quot;@xml/network_security_config&quot;
      android:theme=&quot;@style/Theme&quot;
      android:requestLegacyExternalStorage=&quot;true&quot;&gt;
      &lt;provider
          android:name=&quot;androidx.core.content.FileProvider&quot;
          android:exported=&quot;false&quot;
          android:authorities=&quot;app.provider&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;
      &lt;activity android:name=&quot;.MainActivity&quot;&gt;
          &lt;intent-filter&gt;
              &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
  
              &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  <p>Could anyone help me please?
  Thank you! :)</p>