I'd check with Dave Hylands about this code, and be sure to test on devices like Leo that have internal and external storage areas and devices that don't. 

The API for multiple storage areas changed a couple of times and I forget the current details: I don't know if the filename we get from mediadb will have a prefix for the storage area or not.

Also, and this might be a problem.  I think mediadb will scan both internal and external storage areas. But when you write a file with getDeviceStorage().addNamed() it will go to whichever storage area is selected in the settings app.  In your use case you want to store the cover to which ever storage area the music is on.  And to do that, I think you need to use navigator.getDeviceStorages()  (i.e. the plural form of the function) and then loop through the storage objects to find the one with the prefix you want.

But like I said, that might be out of date.