I'm now trying to call the resources( in my application they are mp3 files and images). For the mp3 file part, my code goes like this ( not working obviously!)
if(i==1)
{
hoho= MediaPlayer.create(getApplicationContext(), R.raw.univ_day1);
hoho.start();
}
else if (i==2)
{
hoho= MediaPlayer.create(getApplicationContext(), R.raw.univ_day2);
hoho.start();
}
...
In my application, there are hundreds of mp3 file inside the application. So what I want to do is briefly summarize code into something like this.
hoho=MediaPlayer.crate(getApplicationContet(), R.raw.univ_day+"i"); //This also looks really awkward.
If I knew how to write down code just like above one. How can I handle the name of raw files and the form like "R.raw...."? If I can do, then I also can apply similar approach to the image resources.