-2

I've made two versions of my app and uploaded each one to the Play Store. They're identical except the free version expires after 7 days whereas the paid version never expires.

What I want is that when a user installs the paid version then the free version on their device (if it exists) gets replaced by the paid version and also all the user's saved SharedPreferences from the free version move over to the paid version. Is this possible? Or will the user have to manually uninstall the free version as well as lose all their saved settings?

purchaseTest
  • 524
  • 3
  • 15
  • 1
    You can't force uninstall but you can prompt the user to do it. https://stackoverflow.com/questions/4412588/in-android-can-you-delete-an-application-from-another-application/4412959 And as the answer stated below you can use Content Providers/ File Providers to get the SharedPreferences from another app. But unless you are somehow verifying that a user has already used their 7 days they could just download the app again for another 7. If you are verifying you could probably get away with using 1 app, as you can tell the difference between a paid/free user. – avalerio May 28 '21 at 16:19
  • @avalerio Is there a tutorial on how to implement a Content Provider to transfer shared preferences? – purchaseTest May 28 '21 at 17:14
  • 1
    I haven't seen a tutorial for that specifically when Google deprecated the Context.MODE_WORLD_READABLE they said use a Content Provider to do it from now on. It seems there is another solution here that my work since you own both apps. https://stackoverflow.com/questions/11025234/how-can-i-share-a-sharedpreferences-file-across-two-different-android-apps The answer with 47 upvotes tells you how to do it but accepted answer gives some nice tidbits that are good to know if you use it. – avalerio May 28 '21 at 17:30
  • @avalerio does using this method allow me to automatically uninstall my app without the user having to be prompted to do it? https://stackoverflow.com/a/53895680/15603244 – purchaseTest May 28 '21 at 19:48
  • @avalerio I tried that answer you posted but didn't use it because android says that "Shared user IDs cause non-deterministic behavior within the package manager. As such, its use is strongly discouraged and may be removed in a future version of Android." – purchaseTest May 28 '21 at 20:18

1 Answers1

0

A quick Google search resulted in finding Content providers. It seems like this is a solution to your problem.

Jonasvle
  • 5
  • 2