Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
About This eBook
Title Page
Copyright Page
About the Android Deep Dive Series
About the Series Editor
Dedication Page
Contents in Brief
Contents
Preface
Who Should Read This Book
How This Book Is Organized
Example Code
Conventions Used in This Book
Acknowledgments
About the Author
1. Relational Databases
History of Databases
Hierarchical Model
Network Model
The Introduction of the Relational Model
The Relational Model
Relation
Attribute
Tuples
Intension/Extension
Schema
Properties of a Relation
Relationships
Referential Integrity
Relational Languages
Relational Algebra
Union (A ∪ B)
Intersection (A ∩ B)
Difference (A - B)
Cartesian Product (A × B)
Selection (σpredicate (σ))
Projection (Πa1, a2,…,an(A))
Joins
Relational Calculus
Tuple Relational Calculus
Domain Relational Calculus
Database Languages
ALPHA
QUEL
SEQUEL
Summary
2. An Introduction to SQL
Data Definition Language
Tables
CREATE TABLE
ALTER TABLE
DROP TABLE
Indexes
CREATE INDEX
DROP INDEX
Views
CREATE VIEW
DROP VIEW
Triggers
CREATE TRIGGER
DROP TRIGGER
Data Manipulation Language
INSERT
VALUES
SELECT
DEFAULT
UPDATE
DELETE
Queries
ORDER BY
Joins
Summary
3. An Introduction to SQLite
SQLite Characteristics
SQLite Features
Foreign Key Support
Full Text Search
Atomic Transactions
Journal Mode
Write-Ahead-Log (WAL) Mode
Multithread Support
What SQLite Does Not Support
Limited JOIN Support
Read-Only Views
Limited ALTER TABLE Support
SQLite Data Types
Storage Classes
Type Affinity
Summary
4. SQLite in Android
Data Persistence in Phones
Android Database API
SQLiteOpenHelper
SQLiteOpenHelper Constructors
SQLiteOpenHelper.onCreate()
SQLiteOpenHelper.onUpgrade()
SQLiteOpenHelper.onConfigure()
SQLiteOpenHelper.onDowngrade()
Putting It All Together
SQLiteDatabase
Strategies for Upgrading Databases
Rebuilding the Database
Manipulating the Database
Copying and Dropping Tables
Database Access and the Main Thread
Exploring Databases in Android
Accessing a Database with adb
Introduction to adb
Permissions and the Android File System
Finding a Database Location with adb
Connecting to a Database with sqlite3
A Shorthand Approach to adb and sqlite3
Using Third-Party Tools to Access Android Databases
Accessing a Database with Stetho
Summary
5. Working with Databases in Android
Manipulating Data in Android
Inserting Rows into a Table
Updating Rows in a Table
Replacing Rows in a Table
Deleting Rows from a Table
Transactions
Using a Transaction
Transactions and Performance
Running Queries
Query Convenience Methods
Raw Query Methods
Cursors
Reading Cursor Data
Managing the Cursor
CursorLoader
Creating a CursorLoader
Starting a CursorLoader
Restarting a CursorLoader
Summary
6. Content Providers
REST-Like APIs in Android
Content URIs
Exposing Data with a Content Provider
Implementing a Content Provider
onCreate()
insert()
delete()
getType()
query()
update()
bulkInsert() and applyBatch()
Content Resolver
Exposing a Remote Content Provider to External Apps
Provider-Level Permission
Individual Read/Write Permissions
URI Path Permissions
Content Provider Permissions
Content Provider Contract
Allowing Access from an External App
Implementing a Content Provider
Extending android.content.ContentProvider
insert()
delete()
update()
query()
getType()
When Should a Content Provider Be Used?
Content Provider Weaknesses
The Need for Extra Code
Use of URIs and Cursors over Objects
No Convenient Place to Close the Database
Content Provider Strengths
Abstraction Layer for Structured Data
Well Supported by Other Android Components
Handles Interprocess Communication
Summary
7. Databases and the UI
Getting Data from the Database to the UI
Using a Cursor Loader to Handle Threading
Binding Cursor Data to a UI
ListView
RecyclerView
Cursors as Observers
registerContentObserver(ContentObserver)
registerDataSetObserver(DataSetObserver)
unregisterContentObserver(ContentObserver)
unregisterDataSetObserver(DataSetObserver)
setNotificationUri(ContentResolver, Uri uri)
Accessing a Content Provider from an Activity
Activity Layout
Activity Class Definition
Creating the Cursor Loader
Handling Returned Data
Reacting to Changes in Data
Summary
8. Sharing Data with Intents
Sending Intents
Explicit Intents
Implicit Intents
Starting a Target Activity
Receiving Implicit Intents
Building an Intent
Actions
Intent.ACTION_SEND
Intent.ACTION_SEND_MULTIPLE
Extras
EXTRA_TEXT
EXTRA_STREAM
Extra Data Types
Implementing Parcelable
Writing a Parcel
CREATOR
Reading a Parcel
What Not to Add to an Intent
ShareActionProvider
Share Action Menu
Summary
9. Communicating with Web APIs
REST and Web Services
REST Overview
REST-like Web API Structure
Accessing Remote Web APIs
Accessing Web Services with Standard Android APIs
Communicating with the Web Service
Working with JSON
Accessing Web Services with Retrofit
Adding Retrofit to an Android Project
Using Retrofit
Accessing Web Services with Volley
Adding Volley to an Android Project
Using Volley
Persisting Data to Enhance User Experience
Data Transfer and Battery Consumption
Data Transfer and User Experience
Storing Web Service Response Data
Android SyncAdapter Framework
AccountAuthenticator
SyncAdapter
Manually Synchronizing Remote Data
A Short Introduction to RxJava
Adding RxJava Support to Retrofit
Using RxJava to Perform the Sync
Summary
10. Data Binding
Adding Data Binding to an Android Project
Data Binding Layouts
Binding an Activity to a Layout
Using a Binding to Update a View
Reacting to Data Changes
Using Data Binding to Replace Boilerplate Code
Data Binding Expression Language
Summary
Index
Code Snippets
← Prev
Back
Next →
← Prev
Back
Next →