title: Image From sd card to galleryview
body: <p>In my app i want to get the Images from SD card to a specific position and i need to display in gallery,</p>
  
  <p>The code i used is attaching</p>
  
  <pre><code>private Gallery gallery;
  private ImageView imgView;
  int position;
  private byte[] data = { };
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.gridview);
        try{
  
          String filepath = "/sdcard/data/Crak/";
          File imagefile = new File(filepath +"abcd.jpg" );
          FileInputStream fis = new FileInputStream(imagefile);
          Bitmap bi = BitmapFactory.decodeStream(fis);
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
          data = baos.toByteArray();
          System.out.println("cnvrtn");
      }
      catch(Exception e) {
           e.printStackTrace();
  
      }
  
      final Bitmap bitmapimage = BitmapFactory.decodeByteArray(data, 0, data.length);
      position = 0;
      imgView = (ImageView) findViewById(R.id.ImageView01);
      imgView.setImageBitmap(bitmapimage);
  
      gallery = (Gallery) findViewById(R.id.examplegallery);
      gallery.setAdapter(new AddImgAdp(this));
  
      gallery.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView parent, View v, int position,
                  long id) {
              imgView.setImageBitmap(bitmapimage);
              DisplayImage.this.position = position;
          }
      });
      System.out.println("Enter the activity//////////");
  
      imgView.setOnClickListener(new View.OnClickListener() {
          @SuppressWarnings("deprecation")
  
  
          @Override
          public void onClick(View paramView) {
              // TODO Auto-generated method stub
  
          }
      });
  
  }
  
  public class AddImgAdp extends BaseAdapter {
      int GalItemBg;
      private Context cont;
  
      @SuppressWarnings("null")
      public AddImgAdp(Context c) {
          cont = c;
  
          TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
          GalItemBg = typArray.getResourceId(
                  R.styleable.GalleryTheme_android_galleryItemBackground, 0);
          typArray.recycle();
      }
  
      public int getCount() {
          return data.length;
      }
  
      public Object getItem(int position) {
          return position;
      }
  
      public long getItemId(int position) {
          return position;
      }
  
      public View getView(int position, View convertView, ViewGroup parent) {
  
  
          ImageView imgView = new ImageView(cont);
          final Bitmap bitmapimage = BitmapFactory.decodeByteArray(data, 0, data.length);
          imgView.setImageBitmap(bitmapimage);;
          imgView.setLayoutParams(new Gallery.LayoutParams(100, 100));
          imgView.setScaleType(ImageView.ScaleType.FIT_XY);
          imgView.setBackgroundResource(GalItemBg);
  
          return imgView;
  
      }
  }
  </code></pre>
  
  <p>The problems are </p>
  
  <p>1)How can i get all image in the specific folder in SD card<br>
  2) GalleryView is indefiniite or a long one without end</p>