File picker

Use a file picker to permit BlackBerry® device users to select a file from the BlackBerry device.

Class FilePicker
Supported since BlackBerry® Java® SDK 5.0
Example This screen shows a file picker.

For more information about file pickers, see the UI Guidelines.

Code sample: Creating a file picker

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.picker.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.io.*;

public class FilePickerDemo extends UiApplication
{
    public static void main(String[] args)
    {    
        FilePickerDemo theApp = new FilePickerDemo();
        theApp.enterEventDispatcher();
    }
    
    public FilePickerDemo()
    {
        pushScreen(new FilePickerDemoScreen());
    }
}

class FilePickerDemoScreen extends MainScreen
{
    public FilePickerDemoScreen()
    {
        setTitle("File Picker Demo");
        add(new LabelField("Trying file picker"));
        
        UiApplication.getUiApplication().invokeLater(new Runnable()
        {
            public void run()
            {
                FilePicker fp = FilePicker.getInstance();
                FilePickListener fileListener = new FilePickListener();
                fp.setListener(fileListener);           
                fp.show();  
            }
        });
    }
}

class FilePickListener implements FilePicker.Listener 
{   
    public void selectionDone(String str)
    {
        Dialog.alert("You selected " + str);
    }
}
Next topic: Spin box
Previous topic: Date picker

Was this information helpful? Send us your comments.