I've done a bit of searching around and found this post... But i'm new to all this Android/Java lark so wanted a bit of advice.
I have created a bit of code that scans the users SD card, finding all folders but only showing files that are *.mp3, *.MP3 etc. So for example I have:
- /alarms/
- /DCIM/
- /music/
- --------/A/
- ------------/Alice Coooper/
- ------------------------------/Trash/
- --------------------------------------/track 1.mp3
- --------/B/
- ----------- ...etc
- /podcasts/
all folders within the sdcard directory are listed, however, only those at the top end of the music tree have mp3s. Only mp3's are shown in the list, which is perfect.
However, I want to refine this further, and only show the directories in the list that have mp3's either within them, or within their subdirectories. I want my list to stay in a treeview structure for other reasons, and not just list out the directories that contain music. So the result would be:
- /sdcard/
- --------/music/
- ----------------/A/
- -------------------/Alice Cooper/
- ------------------------------------/Trash/
- --------------------------------------------/track 1.mp3
- ----------------/B/
- ------------------- ....etc
Can anyone get me started on how to create this?
I assume that i would need to hit each folder, then move through the sub dirs until i find mp3's. However, I am not sure how I would flag that the Music directory eventually contains mp3's and so should be in the list.
The code that I am using to construct a tree. It is based on this and modded slightly.