Would you like to tell us how we are doing?

You bet No thanks

Sorry about the red box, but we really need you to update your browser. Read this excellent article if you're wondering why we are no longer supporting this browser version. Go to Browse Happy for browser suggestions and how to update.

Choice field: 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

More information

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

Example

This screen shows 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);
    }
}