title: How to share private file between applications without using share intent?
body: <p>I need to create a private file that only my applications can access, so I followed this <a href="https://developer.android.com/reference/androidx/core/content/FileProvider" rel="nofollow noreferrer">approach</a> using android FileProvider to share the file Uri.<br>
  the problem is I don't need to share it using share Intents, I need the application that receives the Uri askes for it when it needs using any connections way like Socket or BroadcastReceiver.<br>
  I'm facing a problem when sending the intent with the broadcast reciever
  The file creator app:</p>
  <pre><code>val contentUri: Uri = getUriForFile(this, AUTHORITY, myFile)
      grantUriPermission(RECIEVER_APP_PACKAGE_NAME, contentUri, Intent.FLAG_GRANT_READ_URI_PERMISSION and Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      val intent = Intent()
      intent.apply {
          component = ComponentName(RECIEVER_APP_PACKAGE_NAME,&quot;$RECIEVER_APP_PACKAGE_NAME.MyReciever&quot;)
          data = contentUri
          clipData = ClipData.newRawUri(&quot;&quot;, contentUri)
          addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
      }
      sendBroadcast(intent)
  </code></pre>
  <p>When onReceive triggered in receiver app</p>
  <pre><code>override fun onReceive(context: Context?, intent: Intent?) {
      Log.i(TAG, &quot;onReceive: ${intent!!.data}&quot;)
      val parcelFileDescriptor = context!!.contentResolver.openFileDescriptor(intent.data!!,&quot;r&quot;)
  }
  </code></pre>
  <p>I get</p>
  <blockquote>
  <p>java.lang.SecurityException: Permission Denial: opening provider androidx.core.content.FileProvider from ProcessRecord{601211e 3719:com.test.reciverapp/u0a144} (pid=3719, uid=10144) that is not exported from UID 10143</p>
  </blockquote>
  <p>any help or ideas?
  My optimal scenario is to make shared dir between my applications only, that any app can create a file and other apps have full control over these files. or the second scenario that one app creates a file and the other can at read it.</p>