Skip to content

Storage Chooser 2.0

Storage Chooser is a directory and file chooser library for Android that let's you obtain paths for a selected files/directories with just few lines of code. Follow documentation and guides below to learn more on how to use this library.

Getting Started

  1. To add storage-chooser to your android project you need to add the below lines of code to top-level build.gradle file:
allprojects {
    repositories {
        maven { url "" }
  1. Add the following to app-level build.gradle file:

Now Build Project! You have successfully added storage-chooser to your app project.

  1. Let's create a simple chooser dialog that let's you choose the root storages of android device. Add these lines of code to your project space where you want to show the chooser:
StorageChooser chooser = new StorageChooser.Builder()
                                .withActivity(MainActivity.this) // replace with your own activity object
  1. Show the chooser by invoking the show() method like this:;
    That's it ! Easy-peasy right ? Jump in to Types of Choosers to know more about this library or if you want to directly know methods of chooser go to Available Configurations

Types of Choosers

There are 2 types of storage-choosers available right now:

  1. File Chooser
  2. Directory Chooser

File Chooser

It let's the user choose only files and can be used when single or multiple file paths needs to be obtained. To use storage-chooser as a file chooser create a chooser object like this:

StorageChooser chooser = new StorageChooser.Builder()

// and show;

Directory Chooser

This type of chooser let's user choose only directory and not files. You can obtain only a single directory path in this type. To use storage-chooser as a file chooser create a chooser object like this:

StorageChooser chooser = new StorageChooser.Builder()

// and show;

Available Configurations

methods parameters compulsary?
withActivity Activity Yes
withFragmentManager FragmentManager (legacy) Yes
withMemoryBar boolean No
withPreference SharedPreferences actionSave(true)
withPredefinedPath String No
setType StoragChooser.DIRECTORY*CHOOSER **_or*** StorageChooser.FILE_PICKER allowCustomPath(true)
showHidden boolean No
setTheme StorageChooser.Theme No
skipOverview boolean, String No
skipOverview boolean No
withContent com.codekidlabs.storagechooser.Content No
filter StorageChooser.FileType No
shouldResumeSession boolean No
setHeadingTypeface String, boolean No
setListTypeface String, boolean No
disableMultiSelect NONE No

A Look at StorageChooser.Theme

The way theming works now is by scheme. You set a color scheme to chooser which is an array (int[]) in your xml. For example:

    <array name="paranoid_theme">
        <!-- Overview -->
        <item>#151515</item> <!--  Top Header bg -->
        <item>#2c9633</item> <!-- header text   -->
        <item>#252525</item> <!-- list bg  -->
        <item>@android:color/white</item> <!--  storage list name text  -->
        <item>#e1e1e1</item> <!-- free space text  -->
        <item>#2c9633</item> <!-- memory bar -->

        <!-- secondary dialog colors -->
        <item>#151515</item> <!-- folder tint -->
        <item>#252525</item> <!-- list bg -->
        <item>@android:color/white</item> <!-- list text -->
        <item>#151515</item> <!-- address bar tint -->
        <item>@color/chevronBgColor</item> <!-- new folder hint tint -->
        <item>#2c9633</item> <!-- select button color -->
        <item>#da6c6c</item> <!-- new folder layour bg -->
        <item>#2c9633</item> <!-- fab multiselect color -->
        <item>#151515</item> <!-- address bar bg -->

Here I have created a color scheme called paranoid_theme which can be then set to chooser by writing

StorageChooser.Theme theme = new StorageChooser.Theme(getApplicationContext());
// and then passing it to builder instance

This way you can have multiple schemes of storage-chooser theme depending upon your use case. This is how paranoid_theme looks:

Default Themes

There are basically 2 default themes available for storage-chooser. Without the setTheme method the theme used by storage-chooser will be default_light color scheme which can be accessed by theme.getDefaultTheme();

and another one is dark theme which follows your app color primarily with dark accent theme.getDefaultDarkTheme(); both of them returns an int[].

Manipulating Default Themes

Since theme.getDefaultTheme(); returns an int array it can be easily manipulated to create your own color scheme through code.

Say if you want to change only the list background to your desired color, you would do something like this

// use the theme instance created above
int[] myScheme = theme.getDefaultTheme();

// setting my own color for list backgrounds
// this is overview dialog list color
myScheme[StorageChooser.Theme.OVERVIEW_BG_INDEX] = getColor(R.color.list_bg);
// this is secondary dialog list color
myScheme[StorageChooser.Theme.SEC_BG_INDEX] = getColor(R.color.list_bg);

// now lets set your custom scheme

// apply it to chooser

Now you have your custom theme with your custom list background.

Localizing Chooser

You can easily localize your chooser through code with Content class.

Content c = new Content();
c.setInternalStorageText("My Storage");
c.setOverviewHeading("Choose Drive");



File filters are good and when your app is made for a specific purpose like choosing songs to be added in a playlist you might not want the user to go into the folders where there are no songs.

Filtering Files by Type

Now you can add filter to builder instance like this builder.filter(StorageChooser.FileType.AUDIO); this will filter out all folders containing audio files for you and thereby reducing some effort from user side.

Filtering Files by Extension

In version 2.0.3+, there is a support for custom file filters, all you need to do is create an ArrayList<String> of all the extensions without the . before it and send it to builder.customFilter() function.

List<String> videoExtensions = new ArrayList<String>();

Issues ?

Raise a github issue here to alert me !