0

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.

Community
  • 1
  • 1
Mr.Adam
  • 294
  • 5
  • 23
  • 2
    It would be helpful if you included the code you're using to scan in your question (you can edit your question to put it in). – Harry Cutts Jun 09 '12 at 10:39

1 Answers1

1

In the end I decided to use the android media library along side a simple folder scanner. I still haven't resolved the problem above but I plan on building in the ability for the user to exclude folders from the search using stored strings.

Mr.Adam
  • 294
  • 5
  • 23