This is how I save an audio file:
try (FileOutputStream out = new FileOutputStream(getFilesDir() + "/output.mp3")) {
System.out.println(getFilesDir());
out.write(audioContents.toByteArray());
System.out.println("Audio content written to file \"output.mp3\"");
}
That works fine but I would like to play that audio file. So I could use:
MediaPlayer mp = MediaPlayer.create(this, R.raw.output);
mp.start();
That wouldn't work, since the second parameter is not the correct path of my audio file. So how can I save my audio file in src/main/res/raw, so that I can use R.raw.ouput
?