Storing your data in a database is one good way to persist your data, but there's a caveat in Android-databases created in Android are visible only to the application that created them. That is to say, a SQLite database created on Android by one application is usable only by that application, not by other applications.
So, if you need to share data between applications, you need to use the content provider model as recommended in Android. This article presents the basics of content providers and how you can implement one.
ContentProvider is a facade -- an API you can implement that exposes databases to other processes. It can be implemented in a way where the data is stored in a SQLite database, but it does not have to be.
Data is provided by the ContentProvider interface, but exposed by the ContentResolver. You could potentially access the implemented ContentProvider via Activity.getContentResolver().getProvider(). However, doing so would couple the requesting class to the implemented ContentProvider
Further to this standardized pattern, the ContentResolver provides several interesting functionalities. For instance, it will notify any content listener that the data has changed. For example, you could listen to any changes occurring within a user's contacts and act upon it

1 comments: