简体   繁体   English

冲突的内容提供商

[英]Conflicting content providers

I am developping an application using a ContentProvider. 我正在使用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. 现在,当我尝试安装这两个应用程序时,我收到一条INSTALL_FAILED_CONFLICTING_PROVIDER错误消息,显然是因为AndroidManifest都声明了相同的内容提供程序。

Is there a way to tell in the Manifest that this content provider should be used only if it doesn't already exists ? 有没有办法在Manifest中说明只有在内容提供程序尚不存在的情况下才应该使用它? 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. 一个解决方案是完整版本将数据从演示内容提供商迁移到完整版内容提供商,但我宁愿避免这种情况。

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 用户安装lite版本
  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 用户卸载lite版本,删除其数据
  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. 您需要在完整版的第一次运行时将数据从lite克隆到完整版以避免此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM