I'm trying to make an android game in which I want the palyer to have the liberty to play offline or online via an email authentification. If online, all the players progress, coins and purchases will be saved on the phones memory into a global, and if he connects via email , the values will be updated to the account and everytime the player is buying something it will be stored there. But in a scenario in which the user plays online and makes a small progress and then plays offline on another phone and makes a big progress or buys some items, how could I keep the bigger progress and the items if the user choses to go online with the account, because I want the account to set the values stocked on server and what was on the phone would be overwritten by the server data. And when the user enters the game, first I check if he isconnected and if he is, again I want to set those values. What is the best procedure to avoid these type of situations?
What you describe would require a fairly sophisticated backend server to maintain all of this information.
You might consider looking into Nakama by Heroic Labs and seeing if that fits your needs, or you can find something similar.
I am not affiliated with them by the way, it's just open source and I have been considering using their tech for my own game.
Either way, it will take more than just knowing best practices in order to implement what you have described.
Also, to answer your question about conflict resolution, usually you would maintain timestamps of all transactions (balance changed, item collected etc.) and you would compare the timestamps with your local information to see which data was newer.
You would also likely add some custom logic to only update certain data this way. An example would be when you have a local device with a higher balance than the online account; you may want to just keep the higher balance instead of taking the online balance if the balance isn't critical to your player economy.
But you'd usually want everything to be server authoritative, to reduce the chance of players hacking balances as an example.