How to work with ES File Explorer
ES File Explorer provides intents PICK_FILE, PICK_DIRECTORY and extras for developers to present an "Open file" or "Select folder".
- Intent
Intent | Action |
com.estrongs.action.PICK_FILE | Select a file |
com.estrongs.action.PICK_DIRECTORY | Select a directory |
- Extras
Extra | Meaning |
com.estrongs.intent.extra.TITLE | Assign a new title to the File Choose Dialog |
- Example
This demo shows how the code works,download [apk], [src]
- When you click the “Open a file” , the code is like:
Intent intent = new Intent("com.estrongs.action.PICK_FILE "); intent.putExtra("com.estrongs.intent.extra.TITLE", “Select File”); … startActivityForResult(intent, REQUEST_CODE_PICK_FILE_TO_OPEN); …
Then the ES File Explorer will show, like:
When the file is clicked and a dialog will be show to choose how to return, select the File Way.
The selected file URI can be obtained in onActivityResult() through getData(), like:
case REQUEST_CODE_PICK_FILE_TO_OPEN: // obtain the filename if (uri != null) { Toast.makeText(this, getString(R.string.open_message) + " " + uri.getPath(), 0).show(); } break;
- When you click the “Open a directory” , the code is like:
Intent intent = new Intent("com.estrongs.action.PICK_DIRECTORY "); intent.putExtra("com.estrongs.intent.extra.TITLE", “Select Directory”); … startActivityForResult(intent, REQUEST_CODE_PICK_DIRECTORY); …
Then the ES File Explorer will show, like:
When the Select button is clicked and the current directory will be returned.