How to get paths of folders that has image or video
<p>I want to create an android gallery app .</p>

<p>How to scan and get paths of folders that includes photos or videos .</p>

<p>I used this code and worked . but when i compare it with Quickpic Gallery in play store , i see the count of folders in my app is less than Quickpic folders</p>

<p>Do you see any problem in this code ?</p>

<pre><code>        Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
    Cursor cursor = ba.context.getContentResolver().query(uri, null, null,
            null, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME);
    if (cursor != null) {
        cursor.moveToFirst();
        int data = cursor
                .getColumnIndex(MediaStore.Images.ImageColumns.DATA);
        int displayName = cursor
                .getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME);
        imageFolders = new HashMap&lt;&gt;();
        do {
            String imageAddress = cursor.getString(data);
            String imageName = cursor.getString(displayName);
            String folderAddress = imageAddress.substring(0,
                    imageAddress.lastIndexOf(imageName) - 1);

            if (!imageFolders.containsKey(folderAddress)) {
                imageFolders.put(folderAddress, imageAddress);
            }
        } while (cursor.moveToNext());
        for (String str : imageFolders.keySet()) {

            ba.raiseEventFromDifferentThread(
                    null,
                    null,
                    0,
                    "result",
                    true,
                    new Object[] { String.format("%s", str),
                            String.format("%s", imageFolders.get(str)) });
        }

    }
</code></pre>