Click here to Skip to main content
15,881,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi . I'v read many android tutorials . Some of them believed: you have to create raw folder inside your project . many of them believed: you have to create raw folder in res ! i did both of them ! but i did'nt succeed .
you know , when i try to Code
Java
MediaPlayer.create(R.raw.myp3)

it says : raw can not be resolved or is not a field
how can i fix it ?
Posted

You are trying to refer to a resource that does not exist. I would suggest you go to http://www.codeproject.com/KB/android/#Android+Tutorial+Contest[^] and study some of the excellent articles on Android programming.
 
Share this answer
 
Say you have placed an mp3 file called "sound.mp3" in the res/raw:
int resourceID=getResources().getIdentifier("sound", "raw", getPackageName());
MediaPlayer mediaPlayer=MediaPlayer.create(this, resourceID);
mediaPlayer.start();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900