Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
krishna85
Posts: 36
Registered: ‎10-12-2012
My Device: developer
My Carrier: developer
Accepted Solution

how to display all the mp3 files in sdcard in a listview in blackberry?

I want to display the mp3 files stored in the SDCard in a listview in blackberry....how to do that.?
Please use plain text.
Developer
simon_hain
Posts: 16,102
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to display all the mp3 files in sdcard in a listview in blackberry?

read in the filenames
http://www.blackberry.com/developers/docs/7.1.0api/javax/microedition/io/file/FileConnection.html#li...
covert in to a vector or similar and display it in a listfield.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
krishna85
Posts: 36
Registered: ‎10-12-2012
My Device: developer
My Carrier: developer

Re: how to display all the mp3 files in sdcard in a listview in blackberry?

i have written a code to display all the files and folders in the SDCard in a list view ... but i dont know  how to filter only .mp3 files and show it in listview pls help ...

the code goes here

 

 

public Listscreen()
        {
        super(MainScreen.VERTICAL_SCROLL|MainScreen.VERTICAL_SCROLLBAR);
            try{
            
            FileConnection fc = (FileConnection)Connector.open("file:///SDCard");
            Enumeration file =fc.list();
            
            while(file.hasMoreElements())
            {
                filevector.addElement(file.nextElement().toString());
                
            }
            Dialog.alert(""+filevector.size());
            }catch(Exception e)
            {
                
            }
            mylist = new ListField();
            mylist.setCallback(this);
            mylist.setSize(filevector.size());
            add(mylist);
            
        }

Please use plain text.
Developer
peter_strange
Posts: 19,602
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to display all the mp3 files in sdcard in a listview in blackberry?

Please use plain text.
Developer
simon_hain
Posts: 16,102
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to display all the mp3 files in sdcard in a listview in blackberry?

don't use I/O like fileconnection on the event thread.
see
http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

use a separate thread instead.

instead of adding all elements you can check the element for ending with "mp3", for example
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
krishna85
Posts: 36
Registered: ‎10-12-2012
My Device: developer
My Carrier: developer

Re: how to display all the mp3 files in sdcard in a listview in blackberry?

thanx for all ur help.. actually i got the answer by changing Enumeration file =fc.list(); to Enumeration file =fc.list("*.amr", false);
Please use plain text.