0

I want this kind of app. I want to create an image gallery with parent folder view, I can get all images (media) in grid view but I want parent folder views for images.

Below is the code:

Cursor imagecursor = managedQuery(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
            null, orderBy);
    int image_column_index = imagecursor.getColumnIndex(MediaStore.Images.Media._ID);
    this.count = imagecursor.getCount();
    this.thumbnails = new Bitmap[this.count];
    this.arrPath = new String[this.count];
    this.thumbnailsselection = new boolean[this.count];
    for (int i = 0; i < this.count; i++) {
        imagecursor.moveToPosition(i);
        int id = imagecursor.getInt(image_column_index);
        int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA);
        thumbnails[i] = MediaStore.Images.Thumbnails.getThumbnail(
                getApplicationContext().getContentResolver(), id,
                MediaStore.Images.Thumbnails.MICRO_KIND, null);
        arrPath[i]= imagecursor.getString(dataColumnIndex);
    }

And getView() method of Adapter

public View getView(int position, View convertView, ViewGroup parent) 
{
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(
                    R.layout.list_item, null);
            holder.imageview = (ImageView) convertView.findViewById(R.id.thumbImage);


            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.imageview.setId(position);

        holder.imageview.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                int id = v.getId();
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse("file://" + arrPath[id]), "image/*");
                startActivity(intent);
            }
        });
        holder.imageview.setImageBitmap(thumbnails[position]);

        holder.id = position;
        return convertView;
    }`

I did that for getting grid views of all images in SD card. How would I make a folder system where I can click on the parent folder then images open?

4
  • 1
    Hi and welcome to StackOverflow. What have you tried so far? Where do you get stuck? Feel free to add this information to your question in order to get decent answers.
    – Ben Weiss
    Jun 13, 2014 at 10:25
  • 1
    Are you need to display images from particular folder.. plz show what you have tried and add information to get quick answers... Jun 13, 2014 at 10:33
  • just like samsung mobiles gallery application hope u understand what i want .
    – sumit
    Jun 13, 2014 at 10:40
  • stackoverflow.com/questions/14727426/… check this link i want something like that, thank you to support guys :)
    – sumit
    Jun 14, 2014 at 6:00

1 Answer 1

1

Try like this..I hope this may help you.

  Cursor imagecursor = getContentResolver().query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        columns, 
                        MediaStore.Images.Media.DATA + " like ? ",
                        new String[] {"%/yourfoldername/%"},  
                        null);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.