title: Android Studio Installation failed since the device already has a newer version
body: <p>We have written a new version of an Android app to upgrade an old one, but would like to extract login username from old apps SharedPreferences on first run after upgrade before overwriting the whole thing with the new data model. build.gradle of the new codebase specifies a newer versionName and versionCode, yet when we try to run from Android Studio onto a device that had the old app installed we get a dialog box with the following error message:</p>
  
  <pre><code>Installation failed since the device already has a newer version of this application.
  In order to proceed, you have to uninstall the existing application.
  
  WARNING. Uninstalling will removed the application data!
  
  Do you want to uninstall the existing application?
  
  [OK] [Cancel]
  </code></pre>
  
  <p>Obviously if we accept it uninstalls the old app along with all the user data and we cannot achieve what we intended.</p>
  
  <p>Cannot find anything on the internet regarding this problem</p>
  
  <p><a href="https://i.stack.imgur.com/2VV8C.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2VV8C.png" alt="error message"></a></p>
  
  <p>OLD APP build.gradle:</p>
  
  <pre><code>versionCode 1
  versionName '1.4.1'
  </code></pre>
  
  <p>NEW APP build.gradle:</p>
  
  <pre><code>versionCode 2
  versionName '2.0.0'
  </code></pre>