1

I hope you all are safe.........question! Can you help me out with this? I am lost! Thank you! I highly appreciate it!

LogCat:

java.lang.IllegalArgumentException: Invalid column name
at com.musicapp.android.musicapp.fragment_all_songs.readSongs(fragment_all_songs.java:64)

code:

            String[] projections = {
                    MediaStore.Audio.Media.ARTIST,
                    MediaStore.Audio.Media.DISPLAY_NAME,
                    MediaStore.Audio.Media.SIZE,
                    MediaStore.Audio.Media.MIME_TYPE,
                    MediaStore.Audio.Media.DEFAULT_SORT_ORDER};

    63        ContentResolver contentResolver = getActivity().getContentResolver();
    64        Cursor cursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,projections,null,null,null);
            if (cursor != null){
                if (cursor.moveToFirst()){
                    do {
                        Song song = new Song();
                        song.artist_Name = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST));
                        song.songTitle = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
                        song.songSize = cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.SIZE));
                        //song.SongCover= cursor.get(Integer.parseInt(MediaStore.Audio.Media.MIME_TYPE));
                        song.genre= cursor.getString(cursor.g

etColumnIndex(MediaStore.Audio.Media.DEFAULT_SORT_ORDER));

                    song_list.add(song);
                }while (cursor.moveToNext());
            }
            cursor.close();
        }

1 Answers1

0

Please try to change MediaStore.Audio.Genres.DEFAULT_SORT_ORDER to MediaStore.Audio.Media.DEFAULT_SORT_ORDER?

ror
  • 3,295
  • 1
  • 19
  • 27