title: shared image file in Kotlin android studio
body: <p>I have an application in which I try to share a photo, but when you share the application it crashes.</p>
  <pre><code>    val bitmap = (imageViewx1.drawable as BitmapDrawable).bitmap
      val nombreArchivo:String=&quot;Shared.jpg&quot;
      val patchload= getExternalFilesDir(Environment.DIRECTORY_PICTURES).toString() + nombreArchivo
      val mifile2 =File(patchload)
      val stream: OutputStream = FileOutputStream(mifile2)
      bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream)
      stream.flush()
      stream.close()
      val shareIntent = Intent(Intent.ACTION_SEND)
      shareIntent.type = &quot;image/jpg&quot;
      val photoFile = File(filesDir, &quot;PicturesShared.jpg&quot;)
      Toast.makeText(this, photoFile.toString(), Toast.LENGTH_SHORT).show()
      shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile))
      startActivity(Intent.createChooser(shareIntent, &quot;Share image using&quot;))
  </code></pre>
  <p>log:</p>
  <pre><code>Process: app.xxxx.appimage, PID: 21588
  android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/app.xxxx.appimage/files/PicturesShared.jpg expobeyond app through ClipData.Item.getUri()
      at android.os.StrictMode.onFileUriExposed(StrictMode.java:1967)
      at android.net.Uri.checkFileUriExposed(Uri.java:2364)
      at android.content.ClipData.prepareToLeaveProcess(ClipData.java:941)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9747)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9753)
      at android.content.Intent.prepareToLeaveProcess(Intent.java:9732)
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1679)
      at android.app.Activity.startActivityForResult(Activity.java:4477)
      at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
      at android.app.Activity.startActivityForResult(Activity.java:4435)
      at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
      at android.app.Activity.startActivity(Activity.java:4800)
      at android.app.Activity.startActivity(Activity.java:4768)
      at app.xxxx.appimage.flip$onCreate$4.onClick(flip.kt:97)
      at android.view.View.performClick(View.java:6259)
      at android.view.View$PerformClick.run(View.java:24732)
      at android.os.Handler.handleCallback(Handler.java:789)
      at android.os.Handler.dispatchMessage(Handler.java:98)
      at android.os.Looper.loop(Looper.java:164)
      at android.app.ActivityThread.main(ActivityThread.java:6694)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:769)
  </code></pre>