samedi 29 août 2015

How to insert new artist into android audio database?

I want to implement a feature, which will allow user to edit artist names of local songs in standard database. That's why I need to insert new artist names to database.

I've tried this code

@Override
    protected void addArtistToDatabase(Artist artist) {
        Uri uri = MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI;
        ContentValues values = new ContentValues();
        values.put(MediaStore.Audio.Artists.ARTIST, artist.getName());
        uri = contentResolver.insert(uri, values);
        long id = Strings.getLongFromString(uri.toString());
        artist.setId(id);
    }

But it throws java.lang.UnsupportedOperationException: Invalid URI content://media/external/audio/artists

But when I tried to add playlists the same way everything works as expected.

Aucun commentaire:

Enregistrer un commentaire