group the media files at querying the content resolver

This commit is contained in:
tibbi 2017-02-27 23:29:19 +01:00
parent 638f4b4d45
commit 4ca455c761
1 changed files with 3 additions and 2 deletions

View File

@ -50,12 +50,13 @@ fun Context.launchSettings() {
fun Context.getParents(): ArrayList<String> {
val uri = MediaStore.Files.getContentUri("external")
val columns = arrayOf(MediaStore.Images.Media.DATA)
val columns = arrayOf(MediaStore.Files.FileColumns.PARENT, MediaStore.Images.Media.DATA)
val where = "${MediaStore.Images.Media.DATA} IS NOT NULL) GROUP BY (${MediaStore.Files.FileColumns.PARENT} "
val parentsSet = HashSet<String>()
var cursor: Cursor? = null
try {
cursor = contentResolver.query(uri, columns, null, null, null)
cursor = contentResolver.query(uri, columns, where, null, null)
if (cursor?.moveToFirst() == true) {
do {
val curPath = cursor.getStringValue(MediaStore.Images.Media.DATA) ?: continue