SQLiteOpenHelper vs ContentProvider

后端 未结 2 999

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

2条回答
  •  春和景丽
    2021-02-04 06:23

    SQLiteOpenHelper is used to manage database creation and open. It is only a helper class for sqlite database and could be used in anywhere with db operation.

    ContentProvider is one of the 4 basic components of android, the other 3 are Activity, Service and Broadcast. ContentProvider is used to manage access to any structured data set, including sqlite database. The data source of ContentProvider could be a databse but not have to be.

    ContentProvider is often used in providing own data to others applications, just like ContactsProvider and CalendarProvider. And it is more safe to provide some specified interface using ContentProvider, compared with providing a database directly.

提交回复
热议问题