Reputation: 55
I'm just starting android development after many years of .net development. My begginners book doesn't make it clear what the difference is between a service and a content provider. first it claims a service is a long running app which exposes it api other applications on the device. This is what a windows or a web servie would do on a pc
But then it states a content provider for the "Contacts" application exposes an API to other applications running on andriod so they can iteract with it. This is exactly what a service does. The both do the same thing. The both allow other apps to interact through their api. So what is the difference. Please point me in a a direction where i can read a more logical description of these two functionsl. As this appears to be just nonesense.
Upvotes: 2
Views: 2977
Reputation: 3025
An Android service is something that runs without a user interface (in contrast to an Activity). Often said to be running in the background. This does not mean that it runs on a separate Thread though.
A content provider is a database abstraction layer. It implements CRUD not necessarily on top of a sql database. Most of the times it does. It is a defined interface to access the data behind it. Often recommended only for clients that are in separate processes than the data. I find it useful for inner application data access too.
Services are documented here and content providers here.
Upvotes: 4