What is the best way to detect when an android app has been upgraded, is there any callback for that?
2 Answers
Use
import com.yourpackage.BuildConfig;
...
int versionCode = BuildConfig.VERSION_CODE;
When your app starts, check your SQLite db or SharedPreferences for your version number, if it's not there or it's lower, the app has been updated and store the new version number. Check for this each time on start if the current versioncode is higher than the stored one.
From https://developer.android.com/guide/topics/manifest/manifest-element.html
android:versionCode
An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number....
You can just check when you start the app if the current version is higher than the last time the app has been started.
Maybe something better exist but it seem to me a simple way to do that

- 497
- 10
- 21
-
Thanx and what is the callBack to capture when the app is started (sorry I am very newbie...) – Moussa May 11 '17 at 08:09
-
2