Reputation: 8959
I'm trying to create a raw folder for my android app which will hold different media files for use later. But I can't seem to be able to reference the created raw folder in my .java classes.
For example: R.? -> This returns a list of all possible resources I can use like the basic drawable, layout and values folder. However it won't display the raw folder.
Is it correct to say that raw is created as a general folder and nothing else? Or does it have to be declared in the AndroidManifest.xml file in order to be recognised as a resource?
Upvotes: 66
Views: 110031
Reputation: 4682
In Android Arctic Fox
Click right on App -> New -> Folder -> Raw Resources Folder
Upvotes: 5
Reputation: 93
You also need to follow the naming convention while putting any media file in raw folder as well. In my case my file name was not correct and it was also prompting me an error that unable to find R file. But as @Kesha said it build successfully while it was prompting me an error as well
Upvotes: 1
Reputation: 1
Another answer on Stack Overflow helped with this. You can just go to Build > Clean Project and that will automatically resolve your issue.
Upvotes: 0
Reputation: 507
When I created raw folder inside res for the first time, I was not able to access it using R.raw but still I use R.raw.music
in my code [showing me error that can not reference to this folder] and when deploy the app that error gone away, my app run without any problem. After that, I was able to access raw folder using R.raw
.
Upvotes: 8
Reputation: 1117
Right click on package click on new on popup then click on android resource directory
a new window will be appear change the resource type to raw copy and past song to raw folder
remember don't drag and drop song file to raw folder and song spell should be in lower case This method is for Android Studio Link
Upvotes: 51
Reputation: 2047
The raw folder must be inside the res folder, otherwise it won't work.
Upvotes: 111
Reputation: 151
Just create 'raw' inside 'res' folder and place media file inside that raw folder. Then try to access that media file through your program like R.raw.mediaFile
Upvotes: 11
Reputation: 4260
General folder will get error if you create and put some file into it. Put some media file into raw folder then you can able to refer the raw folder into your .java files.
Hope it will clear all your doubts.
Upvotes: 14