title: Filtering files in a directory on Android
body: <p>In my app i am getting the images from a folder in gallery and saving it into an array list.Now i want to extract only the files with .jpg extension.How can i do it</p>
  
  <p>The code for  saving to array list is</p>
  
  <pre><code>  private List&lt;String&gt; ReadSDCard()
      {
       //It have to be matched with the directory in SDCard
       File f = new File("sdcard/data/crak");
  
       File[] files=f.listFiles();
  
       for(int i=0; i&lt;files.length; i++)
       {
        File file = files[i];
        /*It's assumed that all file in the path are in supported type*/
        tFileList.add(file.getPath());
       }
       return tFileList;
      }
  </code></pre>