I'm trying to make a music album app that has some song in it and can play them. I made the player but now I am stuck because my player , uses musics in an especial address on sd card and I need to either copy audios or use my installed app's asset (or row) folder that is on device (I don't know if there is this folder on phone's memory or not). If there is a better way please let me know.
here is my code:
public class SongsManager {
// SDCard Path
final String MEDIA_PATH = new String("/sdcard/piano/");
private ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
// Constructor
public SongsManager(){
}
/**
* Function to read all mp3 files from sdcard
* and store the details in ArrayList
* */
public ArrayList<HashMap<String, String>> getPlayList(){
File home = new File(MEDIA_PATH);
if (home.listFiles(new FileExtensionFilter()).length > 0) {
for (File file : home.listFiles(new FileExtensionFilter())) {
HashMap<String, String> song = new HashMap<String, String>();
song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
song.put("songPath", file.getPath());
// Adding each song to SongList
songsList.add(song);
}
}
// return songs list array
return songsList;
}