How to run code only when my app is updated
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2133986/how-to-know-my-android-application-has-been-upgraded-in-order-to-reset-an-alarm">How to know my Android application has been upgraded in order to reset an alarm?</a>  </p>
</blockquote>



<p>I need to run a certain code when my android app is only updated (I specifically want to reschedule alarms).</p>

<p>The did an extensive search on SO and I found that people suggest using SharedPreferences.  I dont think this would be correct as sharedPreferences can be deleted upon restart or by simply clearing the cache. Which means when my app is updated, shared preferences may not exist and I may not know if it is an update or simply fresh install ( or even worse a restart).</p>

<p>So, Is there any other way? Perhaps some sort of intent or some sort of method that executes (kinda like onUpgrade for sqlite).</p>

<p>Please advise . Thank you so much</p>
