Home

Awesome

Banner

Android File Picker🛩️

中文简体

If you're using 0.x version, checkout the README_0.x file.

Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, like its name, is a local file selector framework. Some of his characteristics are described below:

RailReplyCraneShrine

Version Compatibility

It depends on your targetAPI.

Download

Gradle:

In your project build.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

In your module build.gradle:

dependencies {
    implementation 'me.rosuh:AndroidFilePicker:$latest_version'
}

This lib now support AndroidX, check the version below.

Check out releases page to see more versions.

Usage 📑

Permission

You should request permission by yourself, this lib will not request permission for you. See Version Compatibility for more details.

Launch 🚀

FilePickerManager
        .from(context)
        .forResult(FilePickerManager.REQUEST_CODE)

Receive Result

In onActivityResult() callback of the starting Activity or Fragment:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    when (requestCode) {
        FilePickerManager.instance.REQUEST_CODE -> {
            if (resultCode == Activity.RESULT_OK) {
                val list = FilePickerManager.instance.obtainData()
                // do your work
            } else {
                Toast.makeText(this@SampleActivity, "You didn't choose anything~", Toast.LENGTH_SHORT).show()
            }
        }
    }
}

The result is a path list of the selected file (ArrayList<String>()).

Docs


Special Thanks To: