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)

Loading data with CursorLoader


CursorLoader is part of the loader family. Before we dive deep into an example explaining how to use CursorLoader, we will explore a bit about loaders and why it is important in the current scenario.

Loaders

Introduced in HoneyComb (API level 11), loaders serve the purpose of asynchronously serving data in an activity or fragment. The need to have loaders arose from many things: calls to various time-consuming methods on the main UI thread in order to fetch data that leads to a clunky UI, and even in some cases, the dreaded ANR box. This is demonstrated in the following screenshot:

For example, the managedQuery() method, which was deprecated in API 11, was a wrapper around the ContentResolver'squery() method.

In the previous chapter, while highlighting how to fetch data from a content provider inside the query method, we used getContentResolver.query() instead of managedQuery(). Using deprecated methods can lead to problems with future releases and should be...