I have several audios stored in the raw directory of the app and I would like to share it with other applications, like whatsapp for example, but I found the documentation on configuring the File provider very confusing.
AndroidManifest.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:grantUriPermissions="true"
android:exported="false"
android:authorities="com.namepackage.fileprovider">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"/>
</provider>
Here comes the configuration of the filepaths that I have doubt how to solve, it looks like this: filepaths.xml
<paths>
<files-path name="files" path="/" />
And the Intent itself:
File imagePath = new File(context.getFilesDir(), "nomearquivo.mp3");
Uri uri = FileProvider.getUriForFile(context,"com.namepackege.fileprovider",
imagePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setType("audio/mp3");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(share);
But this code does not work, I would like to change it in order to work