Kartik Bhatt
Kartik Bhatt

Reputation: 924

Get Uri of All Images in SDCard in Android

I want to get URI or Path of all the Images of SDCARD.

How I can achieve this ?

Thanks.

Upvotes: 1

Views: 2961

Answers (1)

Chirag
Chirag

Reputation: 56925

Please try this.

String[] STAR = { "*" };

        Cursor cursor = managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI
                , STAR, null, null, null);

        if (cursor != null) 
        {
            if (cursor.moveToFirst()) 
            {
                do 
                {
                    String path = cursor.getString(cursor
                            .getColumnIndex(MediaStore.Images.Media.DATA));

                    Log.i("Path",path);
                }while (cursor.moveToNext());

            }
            cursor.close();
        }

Note

Do not forget to give permission in manifest for reading sdcard.

Upvotes: 5

Related Questions