INTRODUCTION

Many Enterprise-oriented applications fit a broad template: They access data using one or more RESTful APIs. They present the data to the user. They may enable the user to modify the data, and update the data on servers. Enterprise Android is a book about those applications.

WHO THIS BOOK IS FOR

If you are an experienced Java or JavaScript coder, you may have some ideas about how RESTful apps should work. You can correctly think of Android as a Java OS: You write apps in Java and deploy them to an environment that, in some ways, very closely resembles a Java VM. These apps communicate with RESTful APIs to fetch data to present to the user.

But, as with many aspects of Android software development, it pays to look at how Android is designed before wading in. This book was created to give you a substantial head start at applying your experience with RESTful applications and APIs to creating Android apps that are efficient, versatile, and responsive. You will avoid the pitfalls of assuming Android programming is like web programming or client Java programming using Oracle’s class libraries, and be able to do it using Android APIs effectively on the first try.

If you are a beginning Android programmer, and do not have significant experience with iOS or Java, or if you are unsure that RESTful applications are what you need to learn about, you should start with a general introduction to Android. Beginners will appreciate a book like Reto Meier’s excellent Professional Android 4 Application Development (John Wiley & Sons, 2012) or the online tutorials at developer.android.com, which are much improved compared to the early days of Android.

If you are interested in expanding your development horizon beyond device programming by pushing into service-side development, this book builds competence handling application data on both sides of the network.

WHAT THIS BOOK COVERS

This book starts with the basics of creating an Enterprise-oriented Android app that can run on handsets and tablets. But it’s not a beginner’s book. You should, at least, read the online tutorials at Google’s Android Developer’s site before reading this book.

Android uses SQLite, and this book covers SQL and SQLite in enough depth that you will understand how data is stored in SQLite databases in Android systems.

Android wraps SQLite in database classes, and this book covers those classes in depth, as well.

When apps make use of data in the Android environment, they often use a specialized service component called a ContentProvider. This class, and the related ContentResolver class, provide a REST-like interface to data within an Android device. Using these classes has other advantages in building apps that use the observer pattern.

Enabling you to implement an end-to-end observer pattern is a key element of this book. Your data resides in a database behind a RESTful API on your servers. Locally, it is likely to be stored in a SQLite database inside a ContentProvider component. This book shows you how to make sure the data you present to the user is consistent and up to date.

Simplicity is important, too. JSON is a simple way to represent data with simplicity and flexibility where, otherwise, a complex database design might be required. This book shows you how to use JSON with SQLite to maintain simplicity in your implementation. It also shows you a complex Android database and ContentProvider interface, implemented with a conventional approach to database design.

You will create and deploy a server for your front end as you use the examples in this book. In particular, Chapters 5 and 6 come together at the end of Chapter 6 to form an end-to-end example of the techniques covered in this book. You’ll deploy this service on Amazon and Google cloud resources in Chapter 7.

One thing you won’t spend much time on is loading indicators. A networked app should be as responsive as a “local” app. Create, update, and delete (CRUD) should not be interposed between the user and the data the user wants. A very important part of this book explains how to keep CRUD off the network and out of the user’s way, using a lightweight but powerful synchronization protocol. The book completes this approach by introducing an open source framework that encapsulates this approach.

The book concludes with an in-depth tour of Android security.

HOW THIS BOOK IS STRUCTURED

This book is called Enterprise Android because it is about acquiring, presenting, and updating data on devices and using cloud resources, which is the core of most enterprise applications.

This book starts with a brisk-paced introduction to Android programming that puts you on track to make an application for displaying data. This is about as fast an introduction as can be, so don’t be surprised if you need to go to the online tutorials in the Android documentation to go deeper on some basics.

Following this introduction, you will be immersed in the core subject matter of this book: data. The book progresses from the bottom up: how to store data locally, how to make queries, how to get it and serve it from REST APIs, how the observer pattern is implemented in Android idioms, how to update it, and how to make this all happen with or without connectivity and with the best apparent performance. Later in the book, more UI programming oriented toward presenting data is covered. The book closes with a chapter on security.

WHAT YOU NEED TO USE THIS BOOK

This book is about Android software development, and the examples in it require the use of the Android software development kit (SDK), which is available from developer.android.com. The SDK is compatible with the three most widely used desktop operating systems: Windows, Mac OS X, and Linux. You may prefer to use an Android device to run the example code, but you can use an emulator, included in the SDK, running on your desktop computer.


NOTE Database code in Android has been very stable for several versions of the Android OS. Mostly due to the way we cover user interface for database apps, this book assumes you will run your programs on Android 4 or later versions. You can expect most of this book to remain current for future version of Android.

To run the service examples in the book, you’ll need to download the packages in each chapter, including the following: Apache Tomcat, ant, MySQL, and the cygwin toolkit. You’ll also need an Amazon AWS account with manager privileges and a Google account.

CONVENTIONS

To help you get the most from the text and keep track of what’s happening, you’ll see a number of conventions throughout the book.


WARNING Warnings like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text.


NOTE Notes offer tips, hints, tricks, and asides to the current discussion.

As for styles in the text:

  • New terms and important words are highlighted when they are introduced.
  • Keyboard strokes appear like this: Ctrl+A.
  • Filenames, URLs, and code within the text appear like so: persistence.properties.
  • Code appears in two different ways:
    We use a monofont type with no highlighting for most code examples.
    We use bold to emphasize code that’s particularly important in the present context.

SOURCE CODE

As you read the chapters in this book, you will want to run, inspect, and perhaps modify the source code files that accompany the book. Please note that all the code examples in this chapter are available at https://github.com/wileyenterpriseandroid/Examples.git and as a part of the book’s code download at www.wrox.com on the Download Code tab.

To find the source code via the Wrox site, locate the book’s title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain all the source code for the book.


NOTE Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-1-118-18349-6

Alternately, you can go to the main Wrox code download page at http://www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.

ERRATA

We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save another reader hours of frustration and at the same time you will be helping us provide even higher quality information.

To find the errata page for this book, go to http://www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata that has been submitted for this book and posted by Wrox editors.


NOTE A complete book list including links to each book’s errata is also available at www.wrox.com/misc-pages/booklist.shtml.

If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.

P2P.WROX.COM

For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At http://p2p.wrox.com you will find a number of forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

1. Go to p2p.wrox.com and click the Register link.
2. Read the terms of use and click Agree.
3. Complete the required information to join as well as any optional information you wish to provide and click Submit.
4. You will receive an e-mail with information describing how to verify your account and complete the joining process.

NOTE You can read messages in the forums without joining P2P, but in order to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset