Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void fetchSong() {
- final String[] column = {MediaStore.Audio.Media.TITLE,MediaStore.Audio.Media.DURATION,MediaStore.Audio.Media.DATA};
- final String selection = MediaStore.Audio.Media.IS_MUSIC + "!= 0";
- Cursor cursor = getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,column,selection,null,null);
- while (cursor.moveToNext()) {
- Songs songData = new Songs(cursor.getString(0),cursor.getString(1),cursor.getString(2));
- if (new File(songData.getPath()).exists()){
- songsList.add(songData);
- }
- recyclerView.setHasFixedSize(true);
- recyclerView.setLayoutManager(new LinearLayoutManager(this));
- AdapterRecycler adapterRecycler = new AdapterRecycler(this,songsList);
- recyclerView.setAdapter(adapterRecycler);
- recyclerView.getAdapter().notifyDataSetChanged();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment