Skip to content

A light-weight (just 27 KB) android library to let users choose folder / files.

License

Notifications You must be signed in to change notification settings

kashifo/android-folder-picker-library

Repository files navigation

android-folder-picker-library

Demo Bintray Android Arsenal

A light-weight android library to let user's pick folder / files from storage.

Some Example Usages

  • Ask users to select folder for saving your app's files.
  • Ask users to point a folder to import / export data.
  • Ask users to choose file from phone storage for viewing, editing or any process.

Screenshots

Preview Preview Preview
Can pick folders Can create folder Can also pick file

Installation

For your convenience, it is available on jCenter, So just add this in your app dependencies:

    compile 'lib.kashif:folderpicker:2.4'

Usage

To pick folder

Just start FolderPicker activity from your app

        Intent intent = new Intent(this, FolderPicker.class);
        startActivityForResult(intent, FOLDERPICKER_CODE);        

If the user selects folder/file, the name of folder/file will be returned to you on onActivityResult method with the variable name 'data'.

        
        protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
          if (requestCode == FOLDERPICKER_CODE && resultCode == Activity.RESULT_OK) {

              String folderLocation = intent.getExtras().getString("data");
              Log.i( "folderLocation", folderLocation );
            
          }
        }
        

Options

Cusstomization options can be passed as extras to FolderPicker activity.

       //To show a custom title
       intent.putExtra("title", "Select file to upload");
       
       //To begin from a selected folder instead of sd card's root folder. Example : Pictures directory
       intent.putExtra("location", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
       
       //To pick files
       intent.putExtra("pickFiles", true);
       

Click here to see an example

License

Copyleft 2017 Kashif Anwaar.

Licensed under Apache 2.0

Do whatever you want with this library.