title: Unable to share Image using FIle Provider java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri
body: <blockquote>
  <p>java.lang.SecurityException: Permission Denial: reading
  androidx.core.content.FileProvider uri
  content://com.jjdj.jdjjd.jdjjdj/sdcard1/storage/emulated/0/Pictures/Paintings/Painting_440.png
  from pid=27901, uid=1000 requires the provider be exported, or
  grantUriPermission()
  at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:740)
  at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:659)
  at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:602)
  at android.content.ContentProvider$Transport.enforceFilePermission(ContentProvider.java:593)
  at android.content.ContentProvider$Transport.openTypedAssetFile(ContentProvider.java:507)
  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:307)
  at android.os.Binder.execTransactInternal(Binder.java:1021)
  at android.os.Binder.execTransact(Binder.java:994)</p>
  </blockquote>
  <p>Below code has been used for this:</p>
  <pre><code>private fun share(fileName: String) {
      val shareFile = File(getStoragePath(), fileName)
      val contentUri = FileProvider.getUriForFile(activity, SHARED_PROVIDER, shareFile)
      val intentBuilder = contentUri?.let {
          ShareCompat.IntentBuilder.from(activity)
              .setType(&quot;image/*&quot;)
              .addStream(it)
      }
      val chooserIntent = intentBuilder?.createChooserIntent()
      activity.startActivity(chooserIntent)
  }
  </code></pre>
  <p>provider passed in manifest :</p>
  <pre><code>  &lt;provider
              android:name=&quot;androidx.core.content.FileProvider&quot;
              android:authorities=&quot;${applicationId}.jsjsj&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/file_provider_paths&quot; /&gt;
          &lt;/provider&gt;
  </code></pre>
  <p>Path Xml :</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;paths&gt;
      &lt;files-path
          name=&quot;Paintings&quot;
          path=&quot;Paintings/&quot; /&gt;
      &lt;external-path
          name=&quot;Paintings&quot;
          path=&quot;.&quot; /&gt;
      &lt;external-files-path
          name=&quot;Paintings&quot;
          path=&quot;.&quot; /&gt;
      &lt;!-- FOR SD CARD--&gt;
      &lt;root-path
          name=&quot;sdcard1&quot;
          path=&quot;.&quot; /&gt;
  &lt;/paths&gt;
  </code></pre>