I\'m new to Android development. I\'m trying to create an application that reads from the internal database (SQLite) and list all the data in a list (I\'m using listView>
My question is: does the ContentProvider do the same as SQLiteOpenHelper?
ContentProvider
is implemented by application's developer if he or she would allow other developers to access to application's database in their application - simply put for sharing. It's like a server of some database and it's client is ContentResolver
who knows ContentProvider
's authority. For example if you need to get some contacts from your device, than you should use ContentProvider
of Contacts database and more concretely it's Contract classes.
If you know an authority of appropriate ContentProvider
you may comunicate with it using a ContentResolver
object.
In other cases you should interact with database through SQL abstract model which is represented by android.database and android.database.sqlite classes.
And also - ContentProvider
available from the primary API level as one of the main component of application.
From the official documentation:
Before you start building a provider, do the following:
Decide if you need a content provider. You need to build a content provider if you want to provide one or more of the following features:
- You want to offer complex data or files to other applications.
- You want to allow users to copy complex data from your app into other apps.
- You want to provide custom search suggestions using the search framework.