Q:

How do we get all folders containing images using MediaStore class (ANDROID)?

I have used MediaStore Class to get all the folders of images inside storage.
But the problem is it is showing the same folder as many times as the number of images in it.
    public void getImageDirProvider(){
    Uri uri= MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
    String projection[]={MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.BUCKET_ID,MediaStore.Images.Media._ID};
    imageCursor=getActivity().getContentResolver().query(uri,projection,null,null,null);

    if (imageCursor!=null){
        while(imageCursor.moveToNext()){

            bucketName.add(imageCursor.getString(0));
            bucketId.add(imageCursor.getString(1));
        }
    }
}

Here bucketName and bucketId are ArrayLists of String type. 
    @Override
    public int getCount() {
        return bucketName.size();
    }

    @Override
    public Object getItem(int position) {
        return bucketName.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    class Holder {
        ImageView iview;
        TextView tview;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        Holder hold = new Holder();

            convertView = layoutInflater.inflate(R.layout.my_list_adapter, parent, false);

            hold.tview = (TextView) convertView.findViewById(R.id.text_view_adapter);
            hold.iview = (ImageView) convertView.findViewById(R.id.image_view);

        hold.tview.setText(getItem(position).toString());
        hold.iview.setImageResource(android.R.drawable.ic_btn_speak_now);
        return convertView;
    }
}

Above is myCustomAdapter class extending BaseAdapter class.

A:

String projection[]={MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.BUCKET_ID,MediaStore.Images.Media._ID};
you query for every available image hence returning cursor has as many records. So when you cycling over it you of course receive duplicate buckets.
Try to exclude images from query and query only for buckets available like 
String projection[]={MediaStore.Images.Media.BUCKET_DISPLAY_NAME,MediaStore.Images.Media.BUCKET_ID};
if you still recieve duplicate values then try 
String projection[] = {"DISTINCT " + MediaStore.Images.Media.BUCKET_DISPLAY_NAME, MediaStore.Images.Media.BUCKET_ID};

