indraja machani
indraja machani

Reputation: 679

display all the images except from particular bucket display name in android

I am displaying all the sd card images in grid view.The thing is I have to display all the images which are there on external storage of the device and at the same time not to display the camera images.I know that for this I need to get either camera bucket id or bucket display name.I am not getting how to do this.So can anyone please help me how to do this..

Upvotes: 1

Views: 1552

Answers (2)

Abx
Abx

Reputation: 2882

Try this.You might need to modify this

public static ArrayList<String> getPathOfAllImages(Activity activity) {
        ArrayList<String> absolutePathOfImageList = new ArrayList<String>();
        String absolutePathOfImage = null;
        String nameOfFile = null;
        String absolutePathOfFileWithoutFileName = null;
        Uri uri;
        Cursor cursor;
        int column_index;
        int column_displayname;
        int lastIndex;



            uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

            String[] projection = { MediaColumns.DATA,
                    MediaColumns.DISPLAY_NAME };

            cursor = activity.managedQuery(uri, projection, null, null, null);
            column_index = cursor.getColumnIndexOrThrow(MediaColumns.DATA);

            column_displayname = cursor
                    .getColumnIndexOrThrow(MediaColumns.DISPLAY_NAME);


            while (cursor.moveToNext()) {

                absolutePathOfImage = cursor.getString(column_index);
                nameOfFile = cursor.getString(column_displayname);

                lastIndex = absolutePathOfImage.lastIndexOf(nameOfFile);

                lastIndex = lastIndex >= 0 ? lastIndex
                        : nameOfFile.length() - 1;

                absolutePathOfFileWithoutFileName = absolutePathOfImage
                        .substring(0, lastIndex);


                    if (absolutePathOfImage != null&& !absolutePathOfImage.equals("/sdcard/DCMI/")) {
                        absolutePathOfImageList.add(absolutePathOfImage);
                    }

            }

Use absolutePathOfImageList to populate your grid view

Upvotes: 1

Abx
Abx

Reputation: 2882

Usualy camera images are stored in a particular folder,DCMI folder.Just dont display images that are in the DCMI folder,skip that folder while you search for images in your sd card

Upvotes: 1

Related Questions