Just curious.
getContentResolver().query(...)
I know that Loaders run queries on background threads. Does this also apply to inserts, updates and deletes? Should I create AsyncTasks, Threads, etc... for these kinds of calls? Large updates might block my application's main thread.
getContentResolver().insert(...)
Thanks!
A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object.
Conclusion. Although the ContentProvider lacks in thread-safety, often times you will find that no further action is required on your part with respect to preventing potential race conditions.
Stay organized with collections Save and categorize content based on your preferences. Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface.
The content provider normally runs in the UI process thread (which was not open), so in this case of a remote process querying the contentprovider, it would spawn a new instance of the contentprovider upon each query because that separate process (UI thread) was not running at the time.
from Content Provider Basics
Retrieving Data from the Provider
This section describes how to retrieve data from a provider, using the User Dictionary Provider as an example.
For the sake of clarity, the code snippets in this section call ContentResolver.query() on the "UI thread"". In actual code, however, you should do queries asynchronously on a separate thread. One way to do this is to use the CursorLoader class, which is described in more detail in the Loaders guide. Also, the lines of code are snippets only; they don't show a complete application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With