Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Implementation

Angad Singh edited this page Aug 12, 2016 · 9 revisions

File Picker Dialog

  1. Start by creating an instance of DialogProperties.

        DialogProperties properties=new DialogProperties();

    Now 'DialogProperties' has certain parameters.

Parameter Type Function
selection_mode int Selection Mode defines whether a single of multiple Files/Directories have to be selected.
selection_type int Selection Type defines whether a File/Directory or both of these has to be selected.
root File The Parent/Root Directory. List of Files are populated from here. Can be set to any readable directory.
extensions String[] An Array of String containing extensions, Files with only that will be shown. Others will be ignored.
  1. Assign values to each Dialog Property using DialogConfig class.

        properties.selection_mode=DialogConfigs.SINGLE_MODE;
        properties.selection_type=DialogConfigs.FILE_SELECT;
        properties.root=new File(DialogConfigs.DEFAULT_DIR);
        properties.extensions=null;

    Read more about DialogConfigs and other options from here.

  2. Next create an instance of FilePickerDialog, and pass Context and DialogProperties references as parameters.

        FilePickerDialog dialog = new FilePickerDialog(MainActivity.this,properties);
  3. Next, Attach DialogSelectionListener to FilePickerDialog as below,

        dialog.setDialogSelectionListener(new DialogSelectionListener() {
            @Override
            public void onSelectedFilePaths(String[] files) {
                //files is the array of the paths of files selected by the Application User.
            }
        });

    An array of paths is returned whenever user press the select button`.

  4. Use dialog.show() method to show dialog.

    That's It. You are good to move further.

File Picker Preference

Clone this wiki locally