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
migit128
Posts: 27
Registered: ‎11-15-2010
My Device: 8350i

Get a list of all ringtones on the phone

public static Vector ringToneList() {
        String  dirs[] = {
            "file:///store/samples/ringtones/",
            "file:///store/home/user/ringtones/",
        };
        Vector strs = new Vector();
        
        for (int i = 0; i < dirs.length; i++){
            try{
                FileConnection _dir = (FileConnection)Connector.open(dirs[i], Connector.READ);
                if( _dir.exists()){
                    if (_dir.isDirectory()){
                        Enumeration list = _dir.list();
                        while (list.hasMoreElements()){
                        	System.out.println("ADDED ITEM TO THE LIST!");
                            String fileName = (String)list.nextElement();
                            strs.addElement(new MediaFileInfo(new String(dirs[i] + fileName), fileName));
                        }
                    }
                }
            }
            catch(IOException ioe){ }
        }
        return strs;
    }

 

I found this code sample online and edited it a little.  When I call this method in my application, the println statement is never triggers, so I do not believe it's finding any items in the directories I believe to contain ringtones.

 

Any ideas?  Right now, all I'm trying to do is have a drop down list of ringtone names and a play button to play them, but it will eventually be much more.

 

Please use plain text.
Contributor
migit128
Posts: 27
Registered: ‎11-15-2010
My Device: 8350i

Re: Get a list of all ringtones on the phone

Well, the method works on the 8520 version of the simulator, but not the latest... Wierd...

Please use plain text.