I want to know what is the difference between Adapter and Loader in Android. I have already looked up at the documentation but can’t figure out the difference between them. Any help would be appreciated. Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both provide an abstraction for data access, but the Loader performs the query in the background whereas an Adapter executes in the current (presumably UI) thread.
For example, a straightforward way to access a Content Provider is with a SimpleCursorAdapter. But querying large amounts of data directly from an Activity may cause it to become blocked resulting in an “Application Not Responding” message. Even if it doesn’t, users will see an annoying delay in the UI. To avoid these problems, you should initiate a query on a separate thread, wait for it to finish, and then display the results. This is what the CursorLoader will do.
That being said, they are sometimes used in conjunction with one another. In this example data is first loaded with a CursorLoader and then that cursor is updated in an Adapter of an AdapterView for display.