Fix NPE on wifi connect

This fixes a NPE when wifi connection is done, this is because database is not open when we try to query number of tracks and application is not oppened (part of inverse's commit "Wifi Scrobble").