Next create an instance of FilePickerDialog, and pass Context and DialogProperties references as parameters. Optional: You can change the title of dialog. Default is current directory name. Set the positive button string. Default is Select. Set the negative button string. Defalut is Cancel.

dialog.setDialogSelectionListener(newDialogSelectionListener() {
@OverridepublicvoidonSelectedFilePaths(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`.

Use dialog.show() method to show dialog.

NOTE:

Marshmallow and above requests for the permission on runtime. You should override onRequestPermissionsResult in Activity/AppCompatActivity class and show the dialog only if permissions have been granted.

//Add this method to show Dialog when the required permission has been granted to the app.@Overridepublicvoid onRequestPermissionsResult(int requestCode,@NonNullString permissions[],@NonNullint[] grantResults) {
switch (requestCode) {
caseFilePickerDialog.EXTERNAL_READ_PERMISSION_GRANT: {
if (grantResults.length >0&& grantResults[0] ==PackageManager.PERMISSION_GRANTED) {
if(dialog!=null)
{ //Show dialog if the read permission has been granted.
dialog.show();
}
}
else {
//Permission has not been granted. Notify the user.Toast.makeText(MainActivity.this,"Permission is Required for getting list of files",Toast.LENGTH_SHORT).show();
}
}
}
}

Important:

defaultValue can have multiple paths, there should be a ':' between two paths.

extensions must not have '.'.

extensions should end with ':' , also have ':' between two extensions. eg. /sdcard:/mnt:

License

Copyright (C) 2019 FilePicker
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.