-
-
Save novoda/374533 to your computer and use it in GitHub Desktop.
//Retrieve a list of Music files currently listed in the Media store DB via URI. | |
//Some audio may be explicitly marked as not being music | |
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"; | |
String[] projection = { | |
MediaStore.Audio.Media._ID, | |
MediaStore.Audio.Media.ARTIST, | |
MediaStore.Audio.Media.TITLE, | |
MediaStore.Audio.Media.DATA, | |
MediaStore.Audio.Media.DISPLAY_NAME, | |
MediaStore.Audio.Media.DURATION | |
}; | |
cursor = this.managedQuery( | |
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, | |
projection, | |
selection, | |
null, | |
null); | |
private List<String> songs = new ArrayList<String>(); | |
while(cursor.moveToNext()){ | |
songs.add(cursor.getString(0) + "||" + cursor.getString(1) + "||" + cursor.getString(2) + "||" + cursor.getString(3) + "||" + cursor.getString(4) + "||" + cursor.getString(5)); | |
} |
Thtat greate Thank you so much
Is using a content provider the right way to go about it? That is if you want to go from scratch?
Hello every one, i recently created and Android class library for actions concerning the MediaStore and acces to media content on a device, It Called MediaFacer and it also support android 10 and 11 MediaStore changes. and it very easy to use
@shakeelAhmad123 what you are asking for can be done in few lines of code with MediaFacer read this Medium article to understand how it works android.jlelse.eu/handling-media-files-with-mediafacer-library-for-android-cd9d2ca0dc68?source=friends_link&sk=02eb8a77e0d9f1958045a39550f0e3a0
MediaFacer on GitHub github.com/CodeBoy722/MediaFacer
Thank you so much for this amazing work, this part is making me cry for months and your library helped me learn a lot <3
How to use it?
- You have to add a listview in xml
- Then name that listview and add findviewbyid method to it
- Then use a adaptor whichever you can use
- For eg : ArrayAdapter ad = new ArrayAdapter(this,android.R.id.layout.simple_list_view_1,songs);
listview.setadapter(ad);
then it will list those .mp3 files in your activity!!
Thank you so much for this amazing work, this part is making me cry for months and your library helped me learn a lot, I really appreciate your work :)