Skip to content

abbasalim/FilePickerDialog-master

Repository files navigation

Android File Picker Dialog (Depracated in Androi 11 or Above)

file picker Dialog library for Android

Using

Step 1. Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

dependencies {
	        implementation 'com.github.abbasalim:FilePickerDialog-master:1.6.0'
	}

Open file Or Folder picker:

  public void slctFolderClick(View view) {
        PickerDialog.FolderPicker(this).onFolderSelect(new PickerDialog.FolderClickListener() {
            @Override
            public void onFolderClicked(String FolderPath) {
                Toast.makeText(MainActivity.this, "پوشه انتخاب شد" + "\n" + FolderPath, Toast.LENGTH_SHORT).show();
            }
        });
    }

    public void slctFileClick(View view) {
        PickerDialog.FilePicker(this).onFileSelect(new PickerDialog.FileClickListener() {
            @Override
            public void onFileClicked(File clickedFile) {
                Toast.makeText(MainActivity.this, "انتخاب شد" + "\n" + clickedFile.getName(), Toast.LENGTH_SHORT).show();
            }
        });
    }

Other Options:

  • open Specific Path
  • show Hidden file
  • file Filter

Example FileFilter And Show Hidden Files

ArrayList<FileFilter> ff = new ArrayList<>();
                ff.add(new FileFilter() {
                    @Override
                    public boolean accept(File file) {
                        return file.isDirectory() || file.getName().endsWith(".wave");
                    }
                });
                CompositeFilter cf = new CompositeFilter(ff);
                MainActivity context = (MainActivity) getActivity();
                PickerDialog.FilePicker(context,null,true,cf).onFileSelect(new PickerDialog.FileClickListener() {
                    @Override
                    public void onFileClicked(File clickedFile) {
                       
                    }
                });

Runtime permissions:

You should handle runtime permissions in activity, from what you called Material File Picker.

WaveAcc.ir

Esfandune.ir