Much of the time, an application’s data is tightly bound to that application. For instance, a book reader application will typically have one datafile per book. Other applications on the mobile phone will have no interest in the files that the book reader uses to store books, so those files are tightly bound to the application, and there is no need to make any effort to share the book data. In fact, the Android OS enforces this tight binding so that applications can’t read or write data across packages at all.
However, some applications want to share their data; that is, they want other applications to be able to read and write data within their database. Perhaps the most obvious example is contact data. If each application that required contacts forced the user to maintain a separate database for that specific application, the phone would be all but useless.
Android enables applications to share data using the content provider API. This API enables each client application to query the OS for data it’s interested in, using a uniform resource identifier (URI) mechanism, similar to the way a browser requests information from the Internet.
The client does not know which application will provide the data; it simply presents the OS with a URI and leaves it to the OS to start the appropriate application to provide the result.
The content provider API enables full CRUD access to the content. This means the application can:
Create new records
Retrieve one, all, or a limited ...