Sharing mp3 files from res to another app without using external directory in Android Studio

Viewed 145
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("audio/mp3");
            Uri uri = Uri.parse("android.resource://com.example.application1/" + R.raw.audio_name);
            intent.putExtra(Intent.EXTRA_STREAM,uri);
            startActivity(Intent.createChooser(intent,"Share Sound"));

My first question is that is it possible to directly share a file from res(raw) folder to another app? Also when I run this code, I get a "Unable to attach file" toast message while sending the file to Gmail app, and in Whatsapp a 'null.bin' file gets shared. What should I change to make the code work?

0 Answers
Related