Content Provider
The Content Provider functions as an intermediary, facilitating access to the private data or files of your application by other applications.

FileProvider (Share files with other apps)
Section titled “FileProvider (Share files with other apps)”Setup a provider in AndroidManifest.xml
Section titled “Setup a provider in AndroidManifest.xml”<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/paths" /></provider>Give other apps permission to access app private external storage
Section titled “Give other apps permission to access app private external storage”Create res/xml/paths.xml:
<?xml version="1.0" encoding="utf-8"?><paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-files-path name="external_dir" path="." /></paths>Get URI to share with other apps
Section titled “Get URI to share with other apps”val cameraCaptureUri = FileProvider.getUriForFile( context, "${context.packageName}.provider", File(context.getExternalFilesDir("image"), "image_${System.currentTimeMillis()}.png"))⚠️ Make sure the requested path is defined in the
FILE_PROVIDER_PATHSresource, or else you’ll get a security exception.