codekidX / storage-chooser

Lets user choose files in internal or external storage with just few lines of code.
Mozilla Public License 2.0
719 stars 153 forks source link

WithPredefinedPath not working #96

Open yhs0602 opened 6 years ago

yhs0602 commented 6 years ago
settingPath=getSharedPreferences("path",MODE_PRIVATE);
        String prepath=settingPath.getString(DiskUtil.SC_PREFERENCE_KEY,"/storage/emulated/0/");
        File tmp=new File(prepath);
        if(tmp.isFile())
        {
            tmp=tmp.getParentFile();
            prepath=tmp.getAbsolutePath();
        }
        StorageChooser chooser = new StorageChooser.Builder()
            .withActivity(MainActivity.this)
            .withFragmentManager(getFragmentManager())
            .withMemoryBar(true)
            .allowCustomPath(true)
            .setType(StorageChooser.FILE_PICKER)
            .actionSave(true)
            //.withPreference(settingPath)
            .withPredefinedPath(prepath)
            .build();
// Show dialog whenever you want by
        chooser.show();
// get path that the user has chosen
        chooser.setOnSelectListener(new StorageChooser.OnSelectListener() {
                @Override
                public void onSelect(String path) {
                    SharedPreferences.Editor edi=settingPath.edit();
                    edi.putString(DiskUtil.SC_PREFERENCE_KEY,path);
                    edi.commit();
                    OnChoosePath(path);
                    //Log.e("SELECTED_PATH", path);
                }
            });

Any clues?

codekidX commented 5 years ago

Hey, sorry I couldn't be of much help in this. I will be discontinuing this feature in 3.0 due to many reasons out of which internal path is way different in Chinese OEMs and you cannot guess it.

Although I saw workaround and I might fix it in a release. Thanks for this.