Conflicting content providers

情到浓时终转凉″ 提交于 2019-11-30 17:34:03

问题


I am developping an application using a ContentProvider. It is declared in the manifest :

<provider android:name="foor.bar.FooBarProvider"
          android:authorities="foo.bar.FoorBarProvider" />

Everything is working fine, I can access the provider. The problem is that I want to create a demo version of my app and I want it to share the same content provider so when the user install the full version, the data is kept in sync. Also, it should be possible to install only the full or the demo version. Therefore, I have to include my content provider in both.

Now, when I try to install both apps, I get a INSTALL_FAILED_CONFLICTING_PROVIDER error message, obviously because both AndroidManifest declare the same content provider.

Is there a way to tell in the Manifest that this content provider should be used only if it doesn't already exists ? Or another workaround ?

A solution would be that the full version migrate the data from a demo content provider to the full version content provider, but I would rather avoid that.


回答1:


A solution would be that the full version migrate the data from a demo content provider to the full version content provider, but I would rather avoid that.

Here is the likely sequence of events:

  1. User installs lite version
  2. User users lite version, storing data
  3. User upgrades to full version, but you don't copy over the data per your quoted passage above
  4. User uninstalls the lite version, deleting its data
  5. User gives you a one-star rating on the Market

You need to clone the data from the lite to the full version on the first run of the full version to avoid this problem.



来源:https://stackoverflow.com/questions/3578751/conflicting-content-providers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!