title: How to fetch all images from sd card?
body: <p>I need to fetch all the images from SD card in android.I had already processed to fetch all images and display in a grid view in android, But I'm unable to get all the images, the Images a sorting out only in a specific path.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>import java.io.File;
  import android.os.Bundle;
  import android.os.Environment;
  import android.app.Activity;
  import android.content.Intent;
  import android.util.Log;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.GridView;
  import android.widget.Toast;
  import android.widget.AdapterView.OnItemClickListener;
  
  public class MainActivity extends Activity 
  {
  
      // Declare variables
      private String[] FilePathStrings;
      private String[] FileNameStrings;
      private File[] listFile;
      GridView grid;
      GridViewAdapter adapter;
      File file;
  
      @Override
      public void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.girdview_main_display);
  
          if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) 
          {
              Toast.makeText(this, "Error! No SDCARD Found!", Toast.LENGTH_LONG).show();
          }
          else 
          {
              file = new File(Environment.getExternalStorageDirectory()+ File.separator + "SDImageTutorial");
              file.mkdirs();
          }
  
          if (file.isDirectory()) 
          {
              listFile = file.listFiles();
  
              FilePathStrings = new String[listFile.length];
  
              FileNameStrings = new String[listFile.length];
  
              for (int i = 0; i &lt; listFile.length; i++) 
              {
                  FilePathStrings[i] = listFile[i].getAbsolutePath();
                  FileNameStrings[i] = listFile[i].getName();
              }
          }
  
  
          grid = (GridView) findViewById(R.id.gridView);
  
          adapter = new GridViewAdapter(this, FilePathStrings, FileNameStrings);
  
          grid.setAdapter(adapter);
  
          grid.setOnItemClickListener(new OnItemClickListener() 
          {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) 
              {
                  Intent i = new Intent(MainActivity.this, ViewImage.class);
  
                  i.putExtra("filepath", FilePathStrings);
                  Log.e("ok","fine : "+FilePathStrings);
  
                  i.putExtra("filename", FileNameStrings);
  
                  i.putExtra("position", position);
                  startActivity(i);
                  finish();
              }
          });
      }
  }
  </code></pre>
  
  <p>Manifest.xml Permission</p>
  
  <p></p>