How Can I Use Music In Raw Folder In This Music Player?
I have this code for adding music from sdcard to my music player : public class SongsManager { // SDCard Path final String MEDIA_PATH = new String('/sdcard/'); private
Solution 1:
try this..
Stringpath="android.resource://" + getPackageName() + "/" + R.raw.yourfile;
Solution 2:
Please follow the below steps to achieve this :-
Step 1 :-
Create a raw folder inside res folder, and place the audio file inside that folder.
Step 2 :-
In your activity class, read from the raw folder in this way,
Field[] fields = R.raw.class.getFields();
// This is only if you have multiple files inside raw folder,else simply do
fields.getName()
to get the string file.
for(int count=0; count < fields.length; count++){
int rid = fields[count].getInt(fields[count]);
String filename = fields[count].getName();
flist.add(filename);
}
Step 3:-
Now that you have the file name, you can use it in your audio player.
Stringxyz="android.resource://"+getPackageName()+"/raw/"+(file name);
Hope this helps.
Post a Comment for "How Can I Use Music In Raw Folder In This Music Player?"