Android - sqlite content providers and multithreading

前端 未结 3 2165
花落未央
花落未央 2021-01-02 11:36

I\'m a little confused about content providers. If I have multiple activities in my application do they each get their own instance of the content provider? it\'s just essen

3条回答
  •  北海茫月
    2021-01-02 12:12

    Oops, I lost my unregistered user cookie so can't vote Femi's answer correct.

    The documentation http://developer.android.com/guide/topics/providers/content-providers.html confirms this with "When a query is initiated, the Android system identifies the content provider that's the target of the query and makes sure that it is up and running. The system instantiates all ContentProvider objects; you never need to do it on your own. In fact, you never deal directly with ContentProvider objects at all. Typically, there's just a single instance of each type of ContentProvider. But it can communicate with multiple ContentResolver objects in different applications and processes. The interaction between processes is handled by the ContentResolver and ContentProvider classes. "

提交回复
热议问题