同步到默认的多进程内容提供商 [英] Multiprocess Content Providers synced to default one

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

问题描述

根据 Android文档

的android:多进程

是否内容提供者的一个实例可以在每个客户端进程来创建 - ​​true表示实例可以在多个进程中运行,而假,如果没有。默认值是假。

Whether or not an instance of the content provider can be created in every client process — "true" if instances can run in multiple processes, and "false" if not. The default value is "false".

一般情况下,一个内容提供者在该定义它的应用程序的过程实例。但是,如果该标志被设置为真,该系统可以在每一个过程中,其中有一个想要与它进行交互,从而避免进程间通信的开销的客户机创建实例

Normally, a content provider is instantiated in the process of the application that defined it. However, if this flag is set to "true", the system can create an instance in every process where there's a client that wants to interact with it, thus avoiding the overhead of interprocess communication.

因此​​,如果这个属性被设置为真正然后内容提供商的实例,将在每一个过程中创建的。

Therefore, if this attribute is set to true then an instance of Content Provider will be created in every process.

问题1 这是实例内容提供商或全部内容提供商的副本的参考?

Question 1 Is this instance a reference to the content provider or a copy of the whole content provider?

问题2 系统如何处理同步变回默认的/原始的实施?它是数据源(的SQLite等)需要读/多进程的照顾写入?

Question 2 How does the system handle syncing changes back to the default / original implementation? Is it that the data source (SQLite, etc.) takes care of the multi-process read / writes?

问3 这更是一个受过教育的猜测。最初,存在于拥有该内容提供者的应用程序内容提供商实例。每次的其他应用程序与它进行交互,他们这样做,通过工控机,这意味着这样的:

Question 3 This is more of an educated guess. Originally, there is content provider instance at the application that owns the content provider. Everytime the other apps interact with it, they do so through IPC, which means this :

other app --> IPC --> content provider --> data source

=多进程的真实设置,系统会创建每个进程内容提供商的副本。因此,应用程序不必通过IPC与内容提供商进行交互。

When multiprocess="true" is set, the system creates a copy of the content provider in each process. Therefore, the app does not have to go through IPC to interact with the content provider.

other app ---> content provider ---> data source

内容提供者还可以直接访问的数据源。在这种情况下,它的方法必须是线程/进程安全的,因为其他应用程序将访问它。

The content provider can still directly access the data source. In this case, its methods must be thread/process safe, since other apps will be accessing it as well.

如果此方案是正确的,是线程安全的默认要求该线程安全的实现不同?

If this scenario is correct, is this thread-safety implementation different from the default requirement of thread-safety?

推荐答案

好问题,可惜我找到了答案,它是:不要使用此属性。

Good Questions, sadly I found an answer and it's: Don't use this attribute.

不要使用此,它是从pre-1.0设计的一些老克鲁夫特,这并不
  工作,应该这几天被忽略。只需pretend像
  属性不存在。 :}

Don't use this, it is some old cruft from pre-1.0 design that doesn't work and should be ignored these days. Just pretend like the attribute doesn't exist. :}

...

戴安娜Hackbor

Dianne Hackbor

Android框架工程师

Android framework engineer

<一个href=\"https://groups.google.com/forum/#!topic/android-developers/u9UMJtALSXw\">https://groups.google.com/forum/#!topic/android-developers/u9UMJtALSXw

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

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