I am trying to create an application that just offers edittext and imagebutton. If you press the butten button, the idea is that the album is added to the playlist named in the edittext window. Albums should be randomly selected. It goes without saying that the album tracks must be in the correct order. I can add additional features later, for example. save, overwrite, delete, etc. I have an interface, but I'm struggling with code. I kind of understand the concept of ContentProviders. therefore, the code should:
access to playlists, which, it seems to me, are achieved using MediaStore.Audio.Playlists
access to albums, which, it seems to me, are achieved using MediaStore.Audio. Albums.
add to playlist
I have the following code (most bits received from this site. Thanks btw) to access the playlist, but it crashes with a Null Exception error.
public void checkforplaylists() { //Get a cursor over all playlists. final ContentResolver resolver= MediaProvider.mContentResolver; final Uri uri=MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI; final String id=MediaStore.Audio.Playlists._ID; final String name=MediaStore.Audio.Playlists.NAME; final String[]columns={id,name}; final Cursor playlists= resolver.query(uri, columns, null, null, null); if(playlists==null) { Log.e(TAG,"Found no playlists."); return; } return; }
Who can help?
source share