contents of playlists being deleted but playlist files still exist Sometimes (probably on reset/power-cycle, which I do every now and then) I lost most of the content of my playlists. I have about 15 playlists that I have created. I have put songs in them several times (several hours of work) and then have come back later and found them all empty -- except for 1 or 2 which remain intact. There are .pla files for the playlists in sdcard/Playlists. 

The music files are all on the external sd card.

I have done tests like setting up several playlists, then restarting or power cycling, then checking to see if the content is still there. It usually is. But if I don't use the play for a while then come back, the playlists' contents have been whacked.

Anybody know the 'right' way to store playlists for Android 4.1.x? In some db? Playlist files? Either one? Does one supercede the other?

I have tried both the default player and MixZing player. Phone is Galaxy Note 2 Android 4.1.3.

Sure would be nice to be able to depend on the playlists not being emptied out all the time.... Any clues greatly appreciated! Thanks!
I had a long journey and did some trial and error. I think I've figured this out  - with a big disclaimer that the details may vary between devices, Android versions, music apps and maybe even types of SD card.

The apparent cause

It seems to happen when this happens - this fits my experiments plus the details in the various angry "Arrrrgh why are my playlists empty" forum threads I've read:


Something causes the phone to need to reconnect to the SD card, such as restarting the phone or connecting it to a computer by USB.
Reading the SD card doesn't happen instantly - kinda like plugging a pen drive into a computer, it needs a little time, seconds or maybe a few minutes. The more stuff on the SD card, and the older/slower/cheaper the SD card, the longer this will take. 
The important part - something causes the music app to look at the playlist while the SD card isn't fully connected. It sees a bunch of references to files it can't find.
The music app, instead of sensibly realising that the files are on a card that is being connected, freaks out and deletes each item in the playlist it can't find. If all your music is on the SD card, that means emptying the playlist.




Possible fixes

So far, the first two of these seem to have been enough to fix it for me (Sony music app, Xperia Z3 Compact, 4+ year old nearly full 16GB SD card).


Don't touch the music app until the SD card has definitely finished connecting. For example, wait 5 minutes after restarting the phone or unplugging from a computer. Some versions of Android show a notification like "checking SD card for errors" but in  my testing relying on this wasn't quite enough.
If you use a music widget, move it off home screen 1 and maybe delete it. This was a crucial one for me. If I had the music widget on my first centre home screen, or, if I swiped over to the home screen with the music widget immediately after restarting the phone, the playlists got wiped (even though I hadn't touched the widget or app). If I had the music widget on the home screen one swipe to the right, and I didn't look at that screen until a few minutes after restarting the phone, the playlists didn't get wiped. Clearly the widget being visible on the screen caused the music app to do some startup process which then triggered this problem if the SD card wasn't fully connected yet.
Maybe play a second of a song you know is on the SD card before touching a playlist. I thought this would fix it for me, forcing the music app to have successfully read from the SD card before giving it a reason to look at my playlists, but my music app doesn't seem to work that way. Others might, though.
Test anything else that might start the music app before the SD card has loaded. For example, some phones have music players on the lock screen, or things that auto-start the music player if headphones are plugged in.
Consider getting a faster SD card. This is a last resort option, I've seen people post that this solved it for them. I guess maybe some modern SD cards connect fast enough or leave some sort of trace that stops this happening.