1

I have a recycler view of the audio file, The audio file stored in the raw folder. Now, I want to share my Audio file with other apps. I'm trying this code in adapter clss.

                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(
                        "android.resource://"+ context.getPackageName()+"/raw/" 
                       + songs[getAdapterPosition()]));
                shareIntent.setType("audio/mp3");
                context.startActivity(shareIntent);

But it's not working. How to solve this.

Thanks in advance.

Imran Sk
  • 303
  • 5
  • 17

1 Answers1

0

The mp3 files are in your app's internal storage; other apps can't access your app's internal storage.

In order to share, first store the mp3 files into an external storage, https://developer.android.com/guide/topics/data/data-storage

Then use Content provider from your app to provide the Uri path information of the mp3 files.

Eric Cen
  • 3,616
  • 1
  • 13
  • 17