Awesome
android-folder-picker-library
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
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);
License
Copyleft 2017 Kashif Anwaar.
Licensed under Apache 2.0
Do whatever you want with this library.