Android Raw folders - creation and reference
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?
Solution 1:
The raw folder must be inside the res folder, otherwise it won't work.
Solution 2:
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
Solution 3:
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.
Solution 4:
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
Solution 5:
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
.