Let's assume I have a paid app purchased by a user (I don't use In-app Billing). Is it possible to execute a piece of code on his device to get the date at which this user has purchased my app?
Asked
Active
Viewed 855 times
5
-
Just curious, any particular reason you want this or how would you use this information? – Anonsage Oct 01 '15 at 23:34
-
1@Anonsage This can be useful to enable/disable legacy features for early purchasers of the product. For example, I used to include X, but then I replaced it with Y for new users, but I want to give the previous users both X and Y to avoid any drama... And it must survive a delete / re-install / new device etc. – mm2001 Apr 26 '16 at 04:08
1 Answers
2
This isn't 100% answer to your question, but you can get the time and date of the first install of the app
http://developer.android.com/reference/android/content/pm/PackageInfo.html#firstInstallTime
long installTime = context.getPackageManager()
.getPackageInfo("com.some.package.name", 0)
.firstInstallTime;

Blundell
- 75,855
- 30
- 208
- 233
-
1To expand on this, use `new Date(getPackageManager().getPackageInfo("com.some.package.name", 0).firstInstallTime).toString();` to return a user readable date. – ArmaAK Aug 02 '14 at 07:50
-
Thank you for your help! I haven't yet tried but do you know what they mean by first install (i.e. what is the value returned if the app is uninstalled/installed multiple times)? – Laurent Aug 02 '14 at 08:03
-
From the JavaDoc `The time at which the app was first installed. Units are as per currentTimeMillis().` , why don't you test it out and write the code then uninstall & reinstall, post your findings here for others – Blundell Aug 02 '14 at 08:10
-
1I have tested, unfortunately the time returned is purely local and not correlated to the play store purchase: reinstalling the app returns a fresh value :( – Laurent Aug 02 '14 at 13:14
-
1Well what you could do, is save the date when they install, then use the [Backup Manager]( http://developer.android.com/reference/android/app/backup/BackupManager.html) to Persist this value across installs? – Blundell Aug 02 '14 at 15:17