How to search for files on the phone’s SD card, or where

I want to search for files on mobile phones of users with certain extensions.

I tried to search, but could not find the direct API.

Is there a specific API or is there a tedious way to achieve this. Or is there a mechanism for calling linux calls to search or something similar

thanks

+7
android file filesystems search file-extension
source share
2 answers

You can find the user's SD card through Environment.getExternalStorageDirectory() , after which you can go to find what you need.

+3
source share
  boolean isSDPresent = Environment.getExternalStorageState() .equals(Environment.MEDIA_MOUNTED); if (isSDPresent) { File file[] = Environment.getExternalStorageDirectory().listFiles(); if (file != null) { for (int i = 0; i < file.length; i++) { file[i].getAbsolutePath(); } } } 

Traverse file[] for the required file

+4
source share

All Articles