In order to build our content provider, the next step will be to prepare our core database access and data modifying methods, better known as CRUD methods. This is where the core logic of how we want to interact with our data depending on the insert, query, or delete calls received is specified. We will also implement the Android architecture's life cycle methods such as onCreate()
.
We create an object of our database manager class in onCreate()
. There should be minimum operations in oncreate()
as it runs on the Main UI thread, and it may cause lag for some users. It is good practice to avoid long-running tasks in oncreate()
as it increases the startup time of the provider. It is even recommended to defer database creation and data loading until our provider actually receives a request for the data, that is, to move long-lasting actions to the CRUD methods:
@Override Public Boolean onCreate() { dbm = new...