How to process application updates from free to paid versions while saving any data

Here is the context. I want to have a free version and a premium version of the same application. When people buy the application, I want them to be able to “update” without losing their data, that is, the premium version should be installed on top of the free version. I want to use the same code base and just switch the option to create a premium version. Andoid Market does not allow me to convert a free application into a paid application, so the trivial option is not available.

I am wondering if anyone has tried this successfully. How does the Android Market identify the application - will it think that the premium version is another application and just installs it in parallel?

+3
source share
3 answers

Answer: this is not allowed in the Android Market, because the Market does not allow downloading two applications with the same package name. Android cannot be tricked into installing a premium version of the free version and treating it as an update.

The good news: adding database backup and restore features (copying the database to the SD card and back to the application folder) required a few lines of code. My users will need to install both versions in parallel, back up the database from the free version and restore it to the premium version.

+1
source

My idea is this:

  • android:versionCode android:versionCode +1
  • .

, . , android:versionCode.

, (/data/data/your.package), db.

+1

Instead of backing up the database to and from the SD card (as suggested by @cdonner), which requires permission WRITE_EXTERNAL_STORAGE, the free application can set ContentProviderwhich paid application can use to transfer data.

Be sure to use permissions to protect your content.

+1
source

Source: https://habr.com/ru/post/1749319/


All Articles