Skip to content

Commit

Permalink
group the media files at querying the content resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Feb 27, 2017
1 parent 638f4b4 commit 4ca455c
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ca455c

Please sign in to comment.