Skip to content

Instantly share code, notes, and snippets.

@luca020400
Created February 12, 2021 13:55
Show Gist options
  • Save luca020400/bd115bc037286ace29cb592ec1523dad to your computer and use it in GitHub Desktop.
Save luca020400/bd115bc037286ace29cb592ec1523dad to your computer and use it in GitHub Desktop.
diff --git a/app/src/main/java/org/lineageos/recorder/utils/MediaProviderHelper.java b/app/src/main/java/org/lineageos/recorder/utils/MediaProviderHelper.java
index df30740..4cdcd47 100644
--- a/app/src/main/java/org/lineageos/recorder/utils/MediaProviderHelper.java
+++ b/app/src/main/java/org/lineageos/recorder/utils/MediaProviderHelper.java
@@ -45,6 +45,8 @@ public final class MediaProviderHelper {
private static final String MY_RECORDS_SORT =
MediaStore.Audio.Media.DATE_ADDED + " DESC";
+ private static final String MY_RELATIVE_PATH = "Music/Sound records/";
+
private MediaProviderHelper() {
}
@@ -64,7 +66,7 @@ public final class MediaProviderHelper {
values.put(MediaStore.Audio.Media.ARTIST, "Recorder");
values.put(MediaStore.Audio.Media.ALBUM, "Sound records");
values.put(MediaStore.Audio.Media.DATE_ADDED, System.currentTimeMillis() / 1000L);
- values.put(MediaStore.Audio.Media.RELATIVE_PATH, "Music/Sound records");
+ values.put(MediaStore.Audio.Media.RELATIVE_PATH, MY_RELATIVE_PATH);
values.put(MediaStore.Audio.Media.IS_PENDING, 1);
final Uri uri = cr.insert(MediaStore.Audio.Media.getContentUri(
@@ -175,8 +177,8 @@ public final class MediaProviderHelper {
final Cursor cursor = cr.query(
MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
projection,
- null,
- null,
+ MediaStore.Audio.Media.RELATIVE_PATH + "=?",
+ new String[]{MY_RELATIVE_PATH},
MY_RECORDS_SORT
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment