Updating directly the MMW SQLite database to add and remove songs in device using MMA

Get answers about the current release of MediaMonkey for Android

Moderator: Gurus

PetitPunk
Posts: 4
Joined: Sat Aug 16, 2025 1:16 pm

Updating directly the MMW SQLite database to add and remove songs in device using MMA

Post by PetitPunk »

I have a pretty large MMW library and I use to manually add and remove music on my phone MMA using the wireless sync feature. I'm pretty peculiar in the way I choose the music I want to listen to on either my phone or my computer and I created a code (in R) that directly read MMW SQLite database and randomly create a playlist for me to enjoy.

This code works great on MMW because it creates a m3u file. However, I'm kind of stuck on how I could use the same kind of process to update my music on my phone. I want to run my R code, which can read the SQLite database and select songs for me, and have R automatically update the music that will be sync to my phone.

Here is the algorithm I have in mind:

1. Sync music on phone.
2. Connect to sqlite database .
3. Find all songs available in my library.
4. Randomly choose the songs I want on my phone and extract the trackID.
5. Find all songs already on my phone.
6. Create a new list on the songs I want on my phone using info from 4 and 5.
7. Overwrite the song on my phone using my new list obtained at step 6.
8. Sync my phone so it uploads the new songs and remove the old ones.

I managed much of the steps but not the critical one which is 7. I have no idea if it's even possible. I was expecting to find a field in the `Songs` table that toggle sync with the proper device ID but I couldn't find it.

I also tried to create a new `DeviceTracks` table and overwrite it in the database but as soon as I sync MMA again, I loose my changes and they are not taken into account.

Another note: it's very important for me to keep my playcount and my LastPlayed information. I use MMA and MMW to keep track of all of that. The solution has to make sure the sync is proper between MMW and MMA.

Do you think what I'm trying to do is possible? Any idea which table or field in the SQLite database I should modify to reach my goal? Thanks!