While logging in i.e. online, you need to first authenticate against the server and if it works, store the username and a hashed password in the database.
If you can find the account in the database, then you need to generate a new hash, only if the user has changed the password since the last time he logged.
You need to also authenticate against the local database. Log in using the online version of the app at least once.