title: How to show all images in this gallery app?
body: <p>I'm making a gallery application.</p>
  
  <p>I have the code for that task, but I'd like to show all SD internal storage images. Only I can see a specific folder in my application, I understand why. This is a method that I found on the internet.</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>import android.content.Intent;
  import android.os.Bundle; 
  import android.os.Environment;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.GridView;
  
  import com.instinctcoder.gridview.R;
  
  import java.io.File;
  import java.util.ArrayList;
  import java.util.List;
  
  public class MainActivity extends AppCompatActivity {
      private GridView gridView;
      private GridViewAdapter gridAdapter;
      private List&lt;String&gt; imageItems;
      private String imagePath="";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          //location where photo saved
          imagePath =  Environment.getExternalStorageDirectory().toString() +                           "/DCIM/Camera";//I'd like to add more Folders, but it doesn't work
          imageItems = new ArrayList&lt;&gt;();
  
  
          getImages();
  
          gridView = (GridView) findViewById(R.id.gridView);
          gridAdapter = new GridViewAdapter(this, R.layout.grid_item, imageItems);
          gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
                  String imagePath =   parent.getAdapter().getItem(position).toString();
                  Intent intent = new Intent(MainActivity.this, DetailActivity.class);
                  intent.putExtra("imagePath", imagePath);
  
                  startActivity(intent);
              }
          });
          gridView.setAdapter(gridAdapter);
  
      }
  
  
      private List&lt;String&gt; getImages(){
          new File(imagePath ).mkdirs();
  
          File fileTarget = new File(imagePath);
          File[] files = fileTarget.listFiles();
  
          imageItems.clear();
  
          if (files!=null){
              for (File file: files){
                  imageItems.add(file.getAbsolutePath());
              }
          }
          return imageItems;
      }
  }
  </code></pre>
  
  <p><strong>GridViewAdapter.java</strong></p>
  
  <pre><code>import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import com.bumptech.glide.Glide;
  import com.instinctcoder.gridview.R;
  import java.util.ArrayList;
  import java.util.List;
  
  public class GridViewAdapter extends ArrayAdapter {
      private Context context;
      private List&lt;String&gt; data = new ArrayList&lt;String&gt;();
      private int resourceId;
      private LayoutInflater inflater ;
  
      public GridViewAdapter(Context context, int resourceId, List&lt;String&gt; data) {
          super(context, resourceId, data);
          this.resourceId = resourceId;
          this.context = context;
          this.data = data;
          inflater = LayoutInflater.from(context);
  
      }
  
      static class ViewHolder {
          ImageView image;
      }
  
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View row = convertView;
          ViewHolder holder = null;
          if (row == null) {
              row = inflater.inflate(resourceId, parent, false);
              holder = new ViewHolder();
              holder.image = (ImageView) row.findViewById(R.id.image);
              row.setTag(holder);
          } else {
              holder = (ViewHolder) row.getTag();
          }
  
          Glide.with(context)
                  .load("file://" + data.get(position))
                  .fitCenter()
                  .centerCrop()
                  .into(holder.image);
  
          return row;
      }
  </code></pre>
  
  <p><strong>Detailactivity.java</strong></p>
  
  <pre><code>package com.instinctcoder.gridview.Galeria;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.widget.ImageView;
  
  import com.bumptech.glide.Glide;
  import com.instinctcoder.gridview.R;
  
  public class DetailActivity extends AppCompatActivity {
  
      Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_detail);
  
          String imagePath = getIntent().getStringExtra("imagePath");
  
          ImageView picturesView = (ImageView) findViewById(R.id.image);
          Glide.with(DetailActivity.this)
                  .load("file://" + imagePath)
                  .fitCenter()
                  .centerCrop()
                  .into(picturesView);
  
      }
  
  }
  </code></pre>
  
  <p>In manifest I have declared permissions storage, parent activity.
  Also, I'm add glide library on gradle.</p>