Book Image

Android SQLite Essentials

By : Sunny Kumar Aditya, Vikash Kumar Karn
Book Image

Android SQLite Essentials

By: Sunny Kumar Aditya, Vikash Kumar Karn

Overview of this book

<p>SQLite is an open source relational database management system. Android uses the SQLite database to store and retrieve data persistently. The driving force behind the platform is the database, enabling a myriad of choices for developers making cutting-edge applications.</p> <p>Android SQLite Essentials focuses on the core concepts behind building database-driven applications. This book covers the basic and advanced topics with equivalent simplicity and detail, in order to enable readers to quickly grasp and implement the concepts to build an application database.</p> <p>This book takes a hands-on, example-based approach to help readers understand the core topics of SQLite and Android database-driven applications. This book focuses on providing you with latent as well as widespread knowledge about practices and approaches towards development in an easily understandable manner.</p>
Table of Contents (11 chapters)

Implementing the core methods


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().

Initializing the provider through the onCreate() method

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...