Start a Project

Android: Check for File explorer presence

Here, today, we will see how we can check if there is any File Explorer present on the device or not. I had to write a code to select a file from device that an be uploaded on server. But as I started finding the solution I got to know that some devices might not even contain a file explorer. so I implemented a file explorer by myself.

But I was not happy as I wanted that user should use his/her own file explorer if they have one. So i Google it for days and finally found a solution here.

Here I applied a check to firstly get if there is any file explorer present in the device or not. And if present then it will be opened and if not then mine one will start.

Here is the small snippet for the same

After asking for permission ( if your device is above API level 22) you will see a screen like this from where you can select a file you want to upload. To get the path for the file you selected you have to add onActivityResult() method in your activity/ fragment as

And here you go with your File selection from Existing File Explorer.

Source: https://github.com/iPaulPro/aFileChooser/blob/master/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java

Exit mobile version