I am trying to get the last 20 songs which were added to my phone.
I tried this
String[] proj = {"*"};
Uri psUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
String sortOrder = MediaStore.Audio.Media.DATE_ADDED;
Cursor psCursor = contentResolver.query(psUri, proj, selection, null, sortOrder);
if(psCursor == null){
return false;
}
But this is returning songs be some other sorting. It is different from what my native music player is showing.
I also tried doing DATE_MODIFIED
but that is also returning the same result.
How can I fix this
Try
String sortOrder = MediaStore.Audio.Media.DATE_ADDED + " ASC";
or
String sortOrder = MediaStore.Audio.Media.DATE_ADDED + " DESC";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.