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.

File picker sample app

The file picker sample application demonstrates how to create a UI component that presents a list of folders and files from which a user can select a file. The sample application also demonstrates how to specify the default search location for folders and how to filter files by file extension (for example, how to display only .mp3 files).

File name

Description

FilePickerDemo.java

  • Contains the entry point for the sample application.
  • Contains the FilePickerDemo() constructor, which creates and displays the FilePickerDemoScreen.
  • Contains the FilePickerDemoScreen inner class, which performs the following actions:
    • Creates and displays a button field to allow the user to start the FilePicker.
    • Specifies a filter for file name extensions to display only .mp3 files.
    • Specifies the system music folder as the first folder to be displayed.
    • Creates a listener that displays the selected file.

This sample features the following classes:

net.rim.device.api.ui.picker.FilePicker

This class provides methods to access the user interface for file selection. You can use these methods to display the file selection screen, specify the default folder path, and filter files by file name extensions.

The sample application uses the setPath() method to specify a start path location from which the user can select files. The sample application also uses thesetFilter() method to present files that have a specific file name extension.

Install the sample app

Visit www.blackberry.com/go/filepickersample to download the sample application.

Extract the filepickerdemo.zip file.

On the taskbar, click Start > Programs > Research In Motion > BlackBerry JDE 5.0 > JDE.

Open the workspace that you want to add the sample application to.

In the workspace tree, right-click the project that you want to add the sample application to.

Click Add project to <workspace directory>.

In the Add project to <workspace> dialog box, browse to the folder where you extracted the sample application.

Click the FilePickerDemo.jdp file.

Click Open.

The sample app is also available in github.

Run the sample app

In the workspace where you added the filepickerdemo project, right-click filepickerdemo.

Click Build project.

On the taskbar, click Start > Applications > Research in Motion > BlackBerry JDE 5.0 > Device Simulator.

On the Home screen of the BlackBerry Smartphone Simulator, click the Downloads folder.

Click the File Picker Demo icon.