To launch the file browser and select the files:
Launch the device’s
native file browser by calling the static FileSelect
launch method and store the returned
list of files in the FileSelectDetail
array.
//Launch the device’s native file browser to select multiple picture files from the device’s external storage FileSelectDetail [] arrSelectedFiles = FileSelect.launch(FileSelect.FILE_SYSTEM_EXTERNAL, FileSelect.MEDIA_TYPE_PICTURE, true); if (arrSelectedFiles != null) { System.out.println("number of selected files " + arrSelectedFiles.length); }
Note: The static FileSelect
.launch
method throws an IOException
error if the device’s
native file browser is busy or not ready, and an IllegalArgumentException
error if the startURL
or mediaType
is invalid.
Use the static
attributes of the FileSelectDetail
class to retrieve detailed
information about the selected files such as display name, MIME type,
size, and URL.
// Retrieve detailed information about the selected files on the device if (arrSelectedFiles != null) { for (int i = 0; i < arrSelectedFiles.length; i++) { System.out.println("display_name " + arrSelectedFiles[i].displayName); System.out.println("mime_type " + arrSelectedFiles[i].mimeType); System.out.println("size" + arrSelectedFiles[i].size); System.out.println("url " + arrSelectedFiles[i].url); } }