views:

148

answers:

2

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?

+1  A: 

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.

Macarse
Sounds plausible and that's what I will try. The question is still if Market allows me to upload the same package with different versions as 2 different applications. If all else fails, I will resort to a manual upgrade procedure with database dumps.
cdonner
@cdonner: Good point. I can't upload paid apps from where I am, so I can't test it. Please let us know if they can have the same package name.
Macarse
This is not possible, unfortunately. This is the message that I get when I try to upload the package for a to be created premium app: You have another application on Market with the same package name. Go to that other application, and click upgrade
cdonner
A: 

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.

cdonner