冲突内容提供商 [英] Conflicting content providers

查看:162
本文介绍了冲突内容提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的深化发展ContentProvider的应用程序。它在清单中声明:

 <提供机器人:名称=foor.bar.FooBarProvider
          机器人:当局=foo.bar.FoorBarProvider/>
 

一切工作正常,我可以访问的提供者。问题是,我要创建我的应用程序的演示版本,我希望它共享相同的内容提供商,所以当用户安装完整版,数据保持同步。另外,它应该有可能只安装完整的或演示版本。所以,我必须包括在我的内容提供商的两个

现在,当我尝试安装这两个应用程序,我得到一个* INSTALL_FAILED_CONFLICTING_PROVIDER *错误消息,显然是因为这两个AndroidManifest声明相同的内容提供商。

有没有办法告诉在清单中,该内容提供商应只如果它不已经存在?还是另一种解决方法吗?

有一个解决方案,将是完整版的演示内容提供商到完整版本的内容提供者的数据迁移,但我宁愿避免这种情况。

解决方案
  

有一个解决方案,将是全   版本的数据从一个演示迁移   内容提供商完整版   内容提供商,但我宁愿   避免这种情况。

下面是事件的可能的顺序:

  1. 在用户安装精简版的版本
  2. 用户用户精简版的版本,存储数据
  3. 用户升级到完整版,但你不要过来的数据复制按你的引文上面
  4. 用户卸载精简版的版本,删除其数据
  5. 用户给你一个一星评级市场

您需要从精简版的数据克隆到完整版本的完整版本第一次运行,以避免这个问题。

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.

解决方案

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.

这篇关于冲突内容提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆