Like many others, I will have a "lite" and a "pro" version of my app. They use a database, which will be in the internal storage. I would like a user to be able to buy the pro version and install it without losing the database.
Partial Solution: I've seen other posts on how to have multiple apps use the same database. Essentially, this requires two things:
- both manifests declare the same android:sharedUserId in the manifest,
- one of the apps must open the database using the other app's context.
I tried this and, yes, it works!
The Problem: Uninstalling the lite version deletes the db. Follow this: the user installs the lite version. The lite version creates the database and he happily creates and saves data in it. Later he decides to install the pro. The pro version accesses the db created by the lite and everything works fine. Finally, he unstalls the lite because he doesn't need it any more. Now, the pro will stop working because the db was deleted by Android when the lite version was uninstalled.
What Solution? One solution that comes to mind is to have a third app that owns the database. It is a "do nothing" app which simple gets installed and has the same name as the package. It would have no UI and in fact never be run. Then, the lite and pro apps could be installed or uninstalled with no effect on the db.
Is this a good idea? Is there a better way (other than creating a provider for the db)? If this is a reasonable approach, how do I create an app with no UI that isn't a service?