0

I am working n in the meanwhile learning to code in android
I came across this mediastore which returns all the details about all the mp3 files stored on the card(Internal & External).
But this method is very very slow
I guess that's what has been implemented in the default music application
No wonder it sometimes fails to find out all the files...

I was thinking of implementing a faster search algorithm for this purpose, But am confused with the initial requirements of these algorithms
1: I thought of implementing the Binary search method (Divide n Conquer) to find files, but then the algorithm requires information about the number of files to be scanned.How do I get that?
2: I thought of implementing separate threads for each divided cluster
.But then will it really work?

Plz help me in this!

the last question : How in the world does poweramp find out all the files so quickly,
My android has about 200 songs on the card, but this app only takes some seconds to get them all!!
Really puzzled!!

user2866238
  • 47
  • 2
  • 6

1 Answers1

1

Try this code:

go to Download and DCIM folder there you can use this command to get all files and if you want to filter files then here is the link

 Process process = null;            
    try {
     process = Runtime.getRuntime().exec("ls -l");


    } catch (IOException ez) {

     ez.printStackTrace();
    }
    BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));

    StringBuilder total = new StringBuilder();
    String line;
    try {
     while ((line = in.readLine()) != null) {

       System.out.println("line: "+line.toString());
         total.append(line);
     }
    } catch (IOException ex) {

     ex.printStackTrace();
    }
     System.out.println("Command Output: "+total.toString());
Community
  • 1
  • 1
Ali Imran
  • 8,927
  • 3
  • 39
  • 50
  • Thanks Ali i'll try this out n notify you about the results! – user2866238 Oct 30 '13 at 07:00
  • what makes you say that returning mediastore details is slow. when selecting all music, the cursor is returned in no time at all. What does take time is the display, especially if you add albumart. I have found the smoothie library by Mr Rocha a godsend. Especially if you are learning to code, my advice is search the web (I have found Stackoverflow and Vogella most useful.) . I too am learning and have my app available which manages playlists. Search for Playlist Manager by THEOKLINK where you will find that all music details are presented in a very performant manner. – Theo Nov 01 '13 at 08:44