문제

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 "upgrade" without losing their data, i.e. the premium version should install over the free version. I want to use the same code base and just switch a setting to build the premium version. Andoid Market does not let me convert a free app to a paid app, so the trivial option is not available.

I am curious if someone has tried this successfully. How does Android Market identify an application - will it think that the premium version is a different app and just install it in parallel?

도움이 되었습니까?

해결책 2

The answer is: this is not solvable with Android Market, because Market does not allow the upload of two apps with the same package name. Android cannot be tricked into installing the premium version over the free version and treat it as an upgrade.

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

다른 팁

My idea is the following:

  • Paid version's android:versionCode should be free's android:versionCode +1
  • Both should have the same package.

When paid version is installed, it will replace the free one. Actually it will update it, since it has a higher android:versionCode.

As both have the same package, they will be placed in the same folder ( /data/data/your.package) so the paid app will be able to access the free app db.

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

Be sure to use permissions to secure your content.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top