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://com.google.android.music.MusicContent/audio");
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)))
artists.add(cursor.getString(0));
}}
cursor.close();
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(DatabaseUtils.java:165) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.query(ContentProviderNative.java:421) at android.content.ContentResolver.query(ContentResolver.java:500) at android.content.CursorLoader.loadInBackground(CursorLoader.java:64) at SongParser.getAllArtists(SongParser.java:41) at SongService.onHandleIntent(SongService.java:60) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.os.HandlerThread.run(HandlerThread.java:61)