Content providers
A content provider is very similar to the concept of a DAO; it is an interface between the data and the app that allows different apps to exchange information. We can decide whether we want it to be public or not, whether we want other apps to be able to get data from it, and whether it will only be used internally in our app. The data can be stored in a database such as the one we are about to create. It can be stored in files; for instance, if we want access to videos or pictures from the gallery, we'll use an Android built-in media content provider. Alternatively, it can be obtained from the network:
A content provider must be declared in the manifest as it is a component of our app and also specify whether or not it will be accessible to other apps, which is controlled by the attribute exported. Let's start by creating our own content provider.
To create a content provider, create a MAAProvider
class and extend ContentProvider
. We will be asked to implement the following...