Should Calls To A Content Resolver Be Done In A Service (i.e Separate Thread)?
I'm learning more about content providers in Android and they're performance. For example, if I write my own content provider (subclass ContentProvider) for SQLite operations and t
Solution 1:
If you want to do something in a Non-UI thread, you should usually use an AsyncTask. A service
, on the other hand, is best kept for long tasks.
Solution 2:
The best way to use Content Providers is in AsyncTask
because they are expensive operations that can't run in the main thread.
Android have encapsulated this pattern in what they call loaders they extend AsyncTaskLoader
for do the job in a non UI thread use loaders callbacks and Cursors for retrieve data from the content provider.
Post a Comment for "Should Calls To A Content Resolver Be Done In A Service (i.e Separate Thread)?"