1

Weird thing is, i tried it on a real device and it works fine. Only on emulators it's not working for some reason.

I even tried lowering the api levels, but still not working.

I tried changing the song name only, everytime this line shows up even though i'm not changing the album art.

table album_art has no column named relative_path  

Any idea why it works on a real device without any problem and not on an emulator?

Logcat error when updating tables in MediaStore with new values.

 E/SQLiteLog: (1) table album_art has no column named relative_path
 E/SQLiteDatabase: Error inserting _data=/storage/emulated/0/Music/_.thumbnails/1574144730622.jpg album_id=3 relative_path=Music/.thumbnails/
        android.database.sqlite.SQLiteException: table album_art has no column named relative_path (code 1 SQLITE_ERROR): , while compiling: INSERT INTO album_art(_data,album_id,relative_path) VALUES (?,?,?)
            at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
            at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:986)
            at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:593)
            at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:590)
            at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:61)
            at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:33)
            at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1597)
            at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468)
            at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:3213)
            at com.android.providers.media.MediaProvider.insert(MediaProvider.java:2903)
            at android.content.ContentProvider$Transport.insert(ContentProvider.java:309)
            at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:154)
            at android.os.Binder.execTransactInternal(Binder.java:1021)
            at android.os.Binder.execTransact(Binder.java:994)

Code for changing mp3 info

public void changeMp3Tags(Context c, long songID, long albumID,
                              String title, String artist, String album, String file_path, String year) throws Exception {
        try {

            final Uri musicUri      = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

            final Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
            Uri albumArtUri = ContentUris.withAppendedId(sArtworkUri, albumID);

            ContentResolver resolver = c.getContentResolver();

            String currentTitle     = MediaStore.Audio.Media.TITLE;
            String currentArtist    = MediaStore.Audio.Media.ARTIST;
            String currentAlbumID   = MediaStore.Audio.Media.ALBUM_ID;
            String currentAlbum     = MediaStore.Audio.Media.ALBUM;
            String currentAlbumData = MediaStore.Audio.Media.DATA;
            String currentYear      = MediaStore.Audio.Media.YEAR;

            ContentValues values = new ContentValues();
            values.put(currentTitle, title);
            values.put(currentArtist, artist);
            values.put(currentAlbum, album);
            values.put(currentYear, year);

            ContentValues valuesAlbum = new ContentValues();
            valuesAlbum.put(currentAlbumID, albumID);
            valuesAlbum.put(currentAlbumData, file_path);

            //Update song info.
            String where = MediaStore.Audio.Media._ID + "=?";
            String[] whereVal = {Long.toString(songID)};
            resolver.update(musicUri, values, where, whereVal);

            //Update albumArt.
            resolver.delete(albumArtUri, null,null);
            resolver.insert(sArtworkUri, valuesAlbum);

        }catch (Exception e){
            Log.e(TAG, "Exception caught when changing MP3 tags!", e);
            throw new Exception();
        }
    }
Santanu Sur
  • 10,997
  • 7
  • 33
  • 52
Vince VD
  • 1,506
  • 17
  • 38
  • Can you include the definition for the `album_art` table? – Tim Biegeleisen Nov 19 '19 at 06:37
  • Post you DB helper implementation here – Md. Asaduzzaman Nov 19 '19 at 07:35
  • @Md.Asaduzzaman I have no DB helper, i just use this method to update the MediaStore for media files. – Vince VD Nov 19 '19 at 15:27
  • How do you create table `album_art ` then ? – Md. Asaduzzaman Nov 19 '19 at 15:29
  • @Md.Asaduzzaman That's the weird part, i don't know where that comes from. All i do is pass parameters like song title, song artist, song album etc.. to my changeMp3Tags method and with a ContentResolver i update these values in MediaStore. – Vince VD Nov 19 '19 at 15:32
  • @Md.Asaduzzaman I even removed the code where i update the album art, but still shows table album_art has no column named relative_path on an emulator. On a real device somehow is works fine. – Vince VD Nov 19 '19 at 15:34
  • @Md.Asaduzzaman Maybe it's just an emulator error? A few weeks ago it worked fine but now it doesn't. I'm using API 29 Android 10, maybe because it's quite new it's causing an error? – Vince VD Nov 19 '19 at 15:37

0 Answers0