I realize that this problem can be solved in the future by using some sort of SharedPreferences value that contains the app version and is set only on the very first run. However, I’m considering adding ads to one of my apps and I’d like to not bombard existing users with ads without offering more value to them.
I was wondering, therefore, if there is some sort of innate property that would let me detect this, or if it’s too late to do it for this version as I would have needed to implement that beforehand. Unfortunately, the app is very simple and so at the moment I haven’t even used any preferences. Thanks!
(I considered asking this on AndroidEnthusiasts, but I reasoned that it really is an SDK question that devs would be better able to answer)
No, you cannot detect the app version of a previously downloaded or initially downloaded APK. You can only detect the app version of the current app.
The only way I can think of for you to get around this would be to implement an update in which you have
SharedPreferences, which sets something like"has_downloaded" = true. Once all the users have updated, you update, stop setting the"has_downloaded"variable, and check it instead. If it’strue, it’s one of your initial users, otherwise, show an ad.This is far from a feasible solution, though, if you have a large userbase. I still have users using versions that are 2+ months old. Additionally, if they ever have to reinstall (or if they clear the app data), this data will be lost.
If your app had, previous to now, been saving data, you could check for the presence of this data, and in all future versions, save it under a different name. You still run into the reinstall issue with this method, though.