Let’s use the following method:Now our MainActivity.
java file should look like this:And if we try to run the application we should get the following message:Now let’s show the file explorer.
To do this, we just need to make a new intent and start a new activity:Now if we run the application we will see our file explorer:Great job!Next let’s get the absolute path of the selected file so our file explorer can be put to good use in our app.
We just need to override the onActivityResult method:So now when we click the SELECT button we should get a toast with the absolute path of the selected fileThat’s the final MainActivity.
java class:Depending on your app, from here you may want to open a CSV or a text file and display it for the user to edit.
Maybe you want to open a photo to send in a message.
It all depends what the goals of your app are.
Regardless, your app will now be more powerful with the ability to reach into your users’ device’s file system and provide additional functionality to them.
ResourcesAndroid Simple File Explorer Library (GitHub).