title: How can I get all folders that contain the images using MediaStore?
body: <p>I'm getting all images from the user gallery using this code:</p>
  <pre><code>String[] projection = {MediaStore.Images.Media.DATA};
  Cursor cursor = MediaStore.Images.Media.query(requireContext().getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, MediaStore.Images.Media.DATE_ADDED + &quot; desc&quot;);
  while (cursor.moveToNext()) {
      list.add(cursor.getString(0));
  }
  </code></pre>
  <p>I want to ask how can I get all folders that contain the above images using <a href="https://developer.android.com/reference/android/provider/MediaStore" rel="nofollow noreferrer">MediaStore</a>?</p>
  <p>I googled before posting this question to avoid the duplicated questions but I did not find anything as I want, I found related questions but it is for Android 10 and above.</p>
  <p>Thank you.</p>