0

Is there a way to check the last version of the app, after updating to the newest version?

— edited

I'm sorry because I was not clear. I'm wondering if there is a built-in method instead of saving version value in database or SharedPreferences?

1 Answers1

0

Have a look at the this answer to a previous question. Basically, you use PackageManager to get the current app version and compare it to the previously stored version in a shared preference.

For more details look into the SharedPreference class, and the PackageManager class.

Community
  • 1
  • 1
MJD
  • 1,183
  • 7
  • 13
  • Thanks I thought about that. However I forgot to place a value in my _published_ app. I'm wondering if there is a built-in method? –  Jul 21 '12 at 06:20
  • I don't think there is a way to get the current version of your app. You can know if you have upgraded, but you can't know from what version. What are you trying to do? Maybe there is another way around it. – MJD Jul 21 '12 at 06:29
  • My problem is the old version does not support encryption for password of user. Now I want to encrypt that password and store the _encrypted password_ into `SharedPreferences` with a _same key_. But I think it's impossible in my case. I know the other way. Thanks :-) –  Jul 21 '12 at 06:36
  • 2
    Well, if all your current previous versions do not support encryption, you could query for the version in your SharedPreference. If the key doesn't exist, assume its the old version without support. Otherwise start maintaining that value in a SharedPreference so you can easily preform such data upgrades in the future. – MJD Jul 21 '12 at 06:40