java.lang.IllegalArgumentException: sortOrder not supported


The following code throws the exception in the title on the third and fourth line. Am I missing something? I want to be able to sort by artist name.

  public List<String> getAllArtists(Context context) {

       List<String> artists = new ArrayList<String>();
       String[] projection2 = {MediaStore.Audio.Media.ARTIST};
       String sortOrder = MediaStore.Audio.Artists.ARTIST;
       Uri songUri = Uri.parse("content://");
       CursorLoader cl2 = new CursorLoader(context,
                songUri, projection2, null, null, sortOrder);

       cursor = cl2.loadInBackground();

             while (cursor.moveToNext()) {
               if (cursor.getString(0).length()>0){
                if (!artists.contains(cursor.getString(0)))


return artists;}

Here is the complete stack trace:

03-22 16:49:18.237 2594-2637/php_request E/AndroidRuntime: FATAL EXCEPTION: IntentService[SongService] Process: php_request, PID: 2594 java.lang.IllegalArgumentException: sortOrder not supported at android.database.DatabaseUtils.readExceptionFromParcel( at android.database.DatabaseUtils.readExceptionFromParcel( at android.content.ContentProviderProxy.query( at android.content.ContentResolver.query( at android.content.CursorLoader.loadInBackground( at SongParser.getAllArtists( at SongService.onHandleIntent( at$ServiceHandler.handleMessage( at android.os.Handler.dispatchMessage( at android.os.Looper.loop( at

What you're using is a Uri handled specifically by Google Play Music app, not Android media system. ( is package name of Play Music.) I can imagine that

a) Play Music API cannot be mixed with Android MediaStore API,

b) Play Music content provider does not support sorting in SQL as the error suggests,

c) Play Music API is changing over time so don't use it anyway. (Don't quote me on this.)

Maybe you'd like to use one of Uri constants specified here These are:


If using specified Uri is intended then I suggest removing sortOrder from content provider request and sorting the resulting List afterwards by calling


as described here