Android Database Programming

Progressing

Jason WeiJune 2012

Applying database concepts to mobile applications is straightforward with this practical tutorial aimed at Google’s Android platform. It will walk you through local and external data storage methods, using clear instructions and practical examples.

$23.99

$39.99

RRP $23.99

RRP $39.99

eBook

Print + eBook

Want this title & more?

$16.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781849518123

Paperback212 pages

About This Book

Master the skills to build data-centric Android applications

Go beyond just code by challenging yourself to think about practical use-cases with SQLite and others

Focus on flushing out high level design concepts, before drilling down into different code examples

Who This Book Is For

"Android Database Programming" targets developers who are experienced with databases and other back-end design concepts, but who may want to see these concepts applied to mobile applications. Developers who are experienced with mobile applications and/or the Android platform, but who may not be as familiar with back-end systems and designing/implementing database schemas will find this tutorial equally useful.

Even if you are already experienced with both Android programming and database implementation, but want to further solidify concepts and see a broader scope of data storage methods on Android, this book is your perfect companion.

Table of Contents

Chapter 1: Storing Data on Android

Using SharedPreferences

Internal storage methods

External storage methods

SQLite databases

Summary

Chapter 2: Using a SQLite Database

Creating advanced SQLite schemas

Wrappers for your SQLite database

Debugging your SQLite database

Summary

Chapter 3: SQLite Queries

Methods for building SQLite queries

SELECT statements

WHERE filters and SQL operators

DISTINCT and LIMIT clauses

ORDER BY and GROUP BY clauses

HAVING filters and Aggregate functions

SQL vs. Java performance comparisons

Summary

Chapter 4: Using Content Providers

ContentProvider

Practical use cases

Summary

Chapter 5: Querying the Contacts Table

Structure of the Contacts content provider

Querying for Contacts

Modifying Contacts

Setting permissions

Summary

Chapter 6: Binding to the UI

SimpleCursorAdapters and ListViews

Custom CursorAdapters

BaseAdapters and Custom BaseAdapters

Handling list interactions

Comparing CursorAdapters and BaseAdapters

Summary

Chapter 7: Android Databases in Practice

Local database use cases

Databases as caches

Typical application design

Summary

Chapter 8: Exploring External Databases

Different external databases

Google App Engine and JDO databases

GAE: an example with video games

The PersistenceManager and Queries

Summary

Chapter 9: Collecting and Storing Data

Methods for collecting data

A primer on web scraping

Extending HTTP servlets for GET/POST methods

Scheduling CRON jobs

Summary

Chapter 10: Bringing it Together

Implementing HTTP GET requests

Back to Android: parsing responses

Final steps: binding to the UI (again)

Summary

What You Will Learn

Learn about lighter forms of local data storage such as SharedPreferences

Dive into SQLite databases and learn how to customize and extend them

Examine various SQLite queries to efficiently query for your data

Learn to safely expose your SQLite database to external applications

Understand how to bind your SQLite database to the user interface

Explore various external databases such as Google App Engine and learn how to store/query data on these external platforms

Learn to make network requests to both post and get data from your external data store

In Detail

We live in an increasingly data-centric and data-driven world. On top of that we live in a very mobile-centric world with the rise of Android smart phones and tablet devices and the surge in demand for the Android platform. Along with the demand for more data, there is a demand for efficient, "snappy" applications, and so developers need to have a strong understanding of when different data storage methods are appropriate and when they are not.

Mastering how to use these two fields to successfully create a powerful application will help you boost your knowledge and skills in this area.

"Android Database Programming" is designed to help developers create and design data-centric mobile applications on Google’s Android platform. As the world goes increasingly mobile and as consumers’ demand for data-centric applications rises, knowing how to combine the two effectively will become an increasingly important asset to have as a developer. The book starts by looking at the various local data storage methods on Android, and finishes off by examining external databases and ways you can utilize them from within an Android application.

This book starts by looking at local data storage methods, focusing on writing SQLite databases for your application and also looking at ways to bind these databases to the user interface. The book, through its practical approach, strives to teach you by examples. Each chapter focuses on flushing out high level design concepts, before drilling down into different code examples.

As you continue you will look at external databases, primarily Google’s App Engine platform, and pull things together by helping you understand how you can request, cache, and display this data. The book then teaches the ways and techniques to utilize such external databases from within your application.

Authors

Jason Wei

Jason Wei graduated from Stanford University in 2011 with a B.S. in Mathematical Computational Science, a minor in Statistics, and an M.S. in Management Science & Engineering with a concentration in Machine Learning. He spent his first two years in college with startups in Silicon Valley, and it was at his second startup (BillShrink, Inc) that he was introduced to Android.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.