Android Database Programming
Copyright 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2012
Production Reference: 1230512
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-84951-812-3
www.packtpub.com
Cover Image by Jason Wei ( <>
)
Credits
Author
Jason Wei
Reviewers
Joseph Lau
Prashant Thakkar (Pandhi)
Acquisition Editor
Kartikey Pandey
Lead Technical Editor
Azharuddin Sheikh
Technical Editors
Ankita Shashi
Manmeet Singh Vasir
Project Coordinator
Joel Goveya
Proofreader
Sandra Hopper
Indexer
Rekha Nair
Graphics
Manu Joseph
Production Coordinator
Nilesh R. Mohite
Cover Work
Nilesh R. Mohite
About the Author
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 and Engineering with a concentration on 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.
Since then he has developed a handful of applications ranging from silly screen prank applications to serious financial pricing and modeling tools. He also enjoys working with APIs and competing in application development contests winning a number of contests hosted by companies like Google, MyGengo, IndexTank, amongst others. In addition to developing applications, Jason enjoys writing Android tutorials and sharing his own development experiences on his blog (thinkandroid.wordpress.com), and it was through his blog that he was first invited to be a technical reviewer for the book Learning Android Game Programming .
Jason is currently working as a quantitative trader in New York.
About the Reviewers
Joseph Lau is currently a graduate student at Stanford University, studying towards his M.S. in Computer Science. During his summers, he's interned at LinkedIn and Google in various technical positions. Android programming is a hobby of his, and he has written several Android applications. He believes mobile applications are a key component of technical innovation in the 21st century and thinks it's a great time to pick up Android programming if you haven't yet.
Prashant Thakkar (Pandhi) is a Technical Lead with more than seven years of IT experience. His strengths are Java, J2EE with frameworks like Struts, Hibernate, and related open source frameworks. Prashant has been working on Android for more than two years and has delivered mission-critical Enterprise Mobile Applications. His interests also include Google App Engine for delivering applications in the cloud. Prashant writes about his technical experiments on his blogs at http://ppandhi.wordpress.com and http://androidpartaker.wordpress.com
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at > for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
- Fully searchable across every book published by Packt
- Copy and paste, print and bookmark content
- On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Preface
Today, we live in an increasingly data-centric and data-driven world. We live in a world where companies like Amazon track every item we view and every item we purchase so as to recommend similar products to us. We live in a world where companies like Google store every search query thrown at them so as to recommend better search queries in the future. We live in a world where social media sites like Facebook remember every event and every thought we share with our friends so as to better learn about each of their hundreds of millions of users. We live in an increasingly data-centric world, and so it's imperative that we develop applications with a data-centric perspective.
Take a look around you the growth of mobile devices, such as smart phones and tablets, has been explosive over the last couple of years. This book is meant to be an exploration of data and Android with a quick dive into the various methods the folks over at Google have built into the Android OS. This book not only strives to show you all the different data storage methods available, but also strives to illuminate the strengths and weaknesses of each method. By the end of this book, my goal is for you to be able to craft an efficient, well-designed, and scalable data-centric application.
What this book covers
, Storing Data on Android , focuses on all the different local data storage methods available on Android. It provides ample code examples of each storage method, as well as a comparison of the strengths and weaknesses of each.
, Using a SQLite Database , takes a deeper dive into the most complex and most commonly used form of local data storage the SQLite database by walking you through the implementation of a custom SQLite database.
, SQLite Queries , is designed to be a cursory overview of the SQL query language. It teaches the reader how to construct powerful database queries, which can then be used with any SQLite database.
, Using Content Providers , expands upon the previous SQLite database chapters by showing the reader how to expose his/her database to the entire Android OS through the use of content providers. It walks the reader through a full implementation of a content provider, and finishes with a brief discussion on benefits of making your data public.