For instance, if I have an mp3 in the raw-foler named "hello.mp3" I can reference it in the code with:
- Code: Select all
mp = MediaPlayer.create(getBaseContext(), R.raw.hello);
But how do I replace the last "hello" with the content of a variable, so that I can load different mp3's from R.raw with the same code?
- Code: Select all
// CODE NOT WORKING
String soundFile = "helloagain";
String mpPath = "R.raw." + soundFile;
mp = MediaPlayer.create(getBaseContext(), mpPath);


