I know that after downloading mp3 from your application you need to add it to ContentResolver in order to see it on the music player. I am doing this with the following code:
private void addFileToContentProvider() { ContentValues values = new ContentValues(7); values.put(Media.DISPLAY_NAME, "display_name"); values.put(Media.ARTIST, "artist"); values.put(Media.ALBUM, "album"); values.put(Media.TITLE, "Title"); values.put(Media.MIME_TYPE, "audio/mp3"); values.put(Media.IS_MUSIC, true); values.put(Media.DATA, pathToFile); context.getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values); }
My problem is that I am ready to avoid setting DISPLAY_NAME , ARTIST , ALBUM , TITLE manually.
Is there any way to tell Android to do this from a file? I already used only values.put(Media.DATA, pathToFile); but did not add it to the player.
Is there a way to force a stream that scans sd for music?
source share