I am building music player app for that I gathering data from SDcard which downloaded from the server and save files name into ArrayList
private ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
Now the problem is I want to play mp3 file according to the user click on recycler item so for that, I want index number for the particular name.
How can I get an index for passing name of the mp3 file??
/**
* 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());
Log.d(TAG, "getPlayList() called title = "+file.getName().substring(0, (file.getName().length() - 4))+" Path = "+file.getPath());
// Adding each song to SongList
songsList.add(song);
}
}
// return songs list array
return songsList;
}
Songclass instead of storing properties in a HashMap