How to do network i/o from a ContentProvider?
<p>I have a ContentProvider that serves up content of documents that are stored on a server.  The content is provided to either another Android app via an ACTION_VIEW intent or to a WebView via a content://... URI.  The ContentProvider keeps a cache of documents in the app's cache directory.</p>

<p>Here's the problem.  When the consumer asks for a document that's not in the cache, I need to get it over the network.  When I try this, I get an exception that network access isn't allowed on the application thread.  I'm currently working around this problem by pre-loading the document data in an AsyncTask before passing control to the external app or browser.  This works most of the time, but isn't completely reliable in edge cases like when the app gets swapped out and then reloaded.</p>

<p>Any suggestions?</p>
