Coder Social home page Coder Social logo

kfilechooser's Introduction

kfilechooser

Lightweight Android File Chooser

Feature

  • File and folder chooser mode
  • File and folder name and extension filtering
  • Easy to use

Intall

Add jcenter repositories to your project gradle if not present, usually its automatically added by android studio.

In your application build.gradle dependencies add this line, for grandle <3.0 :

compile 'kbrs.com.kfilechooser:kfilechooser:1.0'

for grandle >=3.0 :

implementation  'kbrs.com.kfilechooser:kfilechooser:1.0'
  • Dont forget to add uses permission in android manifest to read external storage
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>

Usage

  • Minimal usage of this library
KFileChooser.getInstance()
                .setRootDir(Environment.getExternalStorageDirectory())
                .setOnFileChooserResultListener(new KFileChooser.OnFileChooserResultListener() {
                    @Override
                    public void onResult(File fileResult) {
                        if(fileResult!=null){
                            //do your action here    
                        }
                    }

                    @Override
                    public void onCancel(File lastChoosed) {

                    }
                })
                .show(getSupportFragmentManager());
  • In your onResult method dont forget to check if the result file is null or not. Null File instance return if nothing file is choosed.

  • Full usage of this library:

KFileChooser.getInstance()
                .setTitle("My File Chooser")
                .setRootDir(Environment.getExternalStorageDirectory())
                .setSelect(KFileFilter.MODE_SELECT_FILE)  
                /* KFileFilter.MODE_SELECT_FILE || KFileFilter.MODE_SELECT_FOLDER || KFileFilter.MODE_SELECT_FOLDER_ONLY */
                .setExtension("pdf") 
                /* .setExpression( yourRegularExpression ) */
                .setOnFileChooserResultListener(new KFileChooser.OnFileChooserResultListener() {
                    @Override
                    public void onResult(File fileResult) {
                        if(fileResult!=null){
                            //do your action here    
                        }
                    }

                    @Override
                    public void onCancel(File lastChoosed) {

                    }
                })
                .show(getSupportFragmentManager());

Compatibility

This library using DialogFragment and this project minimum target in android 15 or later

kfilechooser's People

Contributors

kalibrantas avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.