Open shubhwicked opened 5 years ago
"\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\"" is not a column in Mediastore which is what the error states.
@shubhwicked your code snippet is from this file https://github.com/google/ringdroid/blob/955039d67252ea7aea5a36933e8ee30110f5ec92/app/src/main/java/com/ringdroid/RingdroidSelectActivity.java#L542
Right?
Yes
Any solutions? Please post it here
Is there any solution?
yes just get rid of MediaStore.Audio.Media.EXTERNAL_CONTENT_URI as this is not a column in the database. It is the uri which you would use.
private final String track_id = MediaStore.Audio.Media._ID;
private final String track_no = MediaStore.Audio.Media.TRACK;
private final String track_name = MediaStore.Audio.Media.TITLE;
private final String artist = MediaStore.Audio.Media.ARTIST;
private final String artist_id = MediaStore.Audio.Media.ARTIST_ID;
private final String duration = MediaStore.Audio.Media.DURATION;
private final String album = MediaStore.Audio.Media.ALBUM;
private final String composer = MediaStore.Audio.Media.COMPOSER;
private final String year = MediaStore.Audio.Media.YEAR;
private final String path = MediaStore.Audio.Media.DATA;
private final String date_added = MediaStore.Audio.Media.DATE_ADDED;
private final Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
like theolink suggested, remove the last item in the array to fix it; leaving you with a code like this:
private static final String[] EXTERNAL_COLUMNS = new String[]{
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.DATA,
MediaStore.Audio.Media.TITLE,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.IS_RINGTONE,
MediaStore.Audio.Media.IS_ALARM,
MediaStore.Audio.Media.IS_NOTIFICATION,
MediaStore.Audio.Media.IS_MUSIC
};
That is what worked for me. I am not yet sure what the consequences of removing "\"" + MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + "\""
are.
As i explained, it is the uri to access the database, not a column in a table. You have it included in your external_columns variable which is wrong, hence the error
applying this projection
return
Caused by: java.lang.IllegalArgumentException: Invalid column "content://media/external/audio/media".
this error. Please help!