Automating mobile for already installed apps

I am working on a mobile automation, I can spy and record for the already installed app but when I try to run the test case, it uninstalls the app from device and install it again. The problem is that the app requires a randomly generated code for activation.
Is there a way to do so.

any solution??

I also want to know this.

You should be able to achieve this by configuring the 'noReset’ and ‘fullReset’ capabilities for appium.