title: How to scan SD card for particular extension of files in android?
body: <p>I am working on a project which contains a module to scan pdf, doc xls files from sd card and make list of them. I also want to make list of folders only.</p>
  
  <p>As I am very new to android. Anyone have idea of achieving this.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class MediaScannerWrapper implements  
  MediaScannerConnection.MediaScannerConnectionClient {
      private MediaScannerConnection mConnection;
      private String mPath;
      private String mMimeType;
  
      // filePath - where to scan; 
      // mime type of media to scan i.e. "image/jpeg". 
      // use "*/*" for any media
      public MediaScannerWrapper(Context ctx, String filePath, String mime){
          mPath = filePath;
          mMimeType = mime;
          mConnection = new MediaScannerConnection(ctx, this);
      }
  
      // do the scanning
      public void scan() {
          mConnection.connect();
      }
  
      // start the scan when scanner is ready
      public void onMediaScannerConnected() {
          mConnection.scanFile(mPath, mMimeType);
          Log.w("MediaScannerWrapper", "media file scanned: " + mPath);
      }
  
      public void onScanCompleted(String path, Uri uri) {
          // when scan is completes, update media file tags
      }
  }
  </code></pre>