When I click a button,show a file browser,I can choose a folder and return it's path.I get this path to copy file to that path.
But I have no idea of How I could implement this.
I have yet looking for this question in Stackoverflow but I haven't find a clear answer to my question.
I saw some libary of filebrowserview like "https://github.com/psaravan/FileBrowserView",but not work.
To view the full path of a folder: Click the Start button and then click Computer, click to open the location of the desired folder, and then right-click to the right of the path in the address bar.
You can use below code to get all images from specific folder. 1) First you need to define File object to get the storage and appened the name of the folder you want to read. File folder = new File(Environment. getExternalStorageDirectory().
Intent intent = new Intent(Intent. ACTION_GET_CONTENT); intent. setType("*/*"); Intent i = Intent. createChooser(intent, "View Default File Manager"); startActivityForResult(i, CHOOSE_FILE_REQUESTCODE);
Use intent for that!
First start start activity for result like this:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
startActivityForResult(intent, PICKFILE_REQUEST_CODE);
Override this method in your activity, it will get called when activity you just started returns. You can handle result codes such as canceled or successful.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String Fpath = data.getDataString();
//TODO handle your request here
super.onActivityResult(requestCode, resultCode, data);
}
Another approach is to use library such as NoNonsense-FilePicker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With