This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.
PDF The popular standard, used most often with the free Adobe® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
Also available in other formats.
Register your product to gain access to bonus material or receive a coupon.
Battle-Tested Strategies for Storing, Managing, and Sharing Android Data
“Android™ Database Best Practices goes well beyond API documentation to offer strategic advice about how to handle data in an Android application and the tools needed to develop productively. This arms the developer with a trove of solutions to nearly any problem an application may face involving data. Mastering the concepts in this book are therefore essential for any developer who wants to create professional Android applications.”
–Greg Milette, Android developer, Gradison Technologies, Inc.
This is the first guide to focus on one of the most critical aspects of Android development: how to efficiently store, retrieve, manage, and share information from your app’s internal database. Through real-world code examples, which you can use in your own apps, you’ll learn how to take full advantage of SQLite and the database-related classes on Android.
A part of Addison-Wesley’s Android™ Deep Dive series for experienced Android developers, Android Database Best Practices draws on Adam Stroud’s extensive experience leading cutting-edge app projects.
Stroud reviews the core database theory and SQL techniques you need to efficiently build, manipulate, and read SQLite databases. He explores SQLite in detail, illuminates Android’s APIs for database interaction, and shares modern best practices for working with databases in the Android environment.
Through a complete case study, you’ll learn how to design your data access layer to simplify all facets of data management and avoid unwanted technical debt. You’ll also find detailed solutions for common challenges in building data-enabled Android apps, including issues associated with threading, remote data access, and showing data to users. Extensive, up-to-date sample code is available for download at github.com/android-database-best-practices/device-database.
Download the sample pages (includes Chapter 5 and the Index.)
About the Author xxi
Chapter 1: Relational Databases 1
History of Databases 1
The Relational Model 3
Relational Languages 9
Database Languages 14
Chapter 2: An Introduction to SQL 17
Data Definition Language 17
Data Manipulation Language 28
Chapter 3: An Introduction to SQLite 39
SQLite Characteristics 39
SQLite Features 39
What SQLite Does Not Support 42
SQLite Data Types 43
Chapter 4: SQLite in Android 47
Data Persistence in Phones 47
Android Database API 47
Strategies for Upgrading Databases 58
Database Access and the Main Thread 60
Exploring Databases in Android 61
Chapter 5: Working with Databases in Android 79
Manipulating Data in Android 79
Running Queries 89
Chapter 6: Content Providers 101
REST-Like APIs in Android 101
Content URIs 102
Exposing Data with a Content Provider 102
Exposing a Remote Content Provider to External Apps 108
Content Provider Contract 112
Allowing Access from an External App 114
Implementing a Content Provider 115
When Should a Content Provider Be Used? 132
Chapter 7: Databases and the UI 137
Getting Data from the Database to the UI 137
Cursors as Observers 143
Accessing a Content Provider from an Activity 145
Chapter 8: Sharing Data with Intents 163
Sending Intents 163
Receiving Implicit Intents 166
Building an Intent 167
Chapter 9: Communicating with Web APIs 177
REST and Web Services 177
Accessing Remote Web APIs 179
Persisting Data to Enhance User Experience 206
Android SyncAdapter Framework 207
Manually Synchronizing Remote Data 218
Chapter 10: Data Binding 231
Adding Data Binding to an Android Project 231
Data Binding Layouts 232
Using Data Binding to Replace Boilerplate Code 242
Data Binding Expression Language 246