Couchbase Lite 2.x is a powerful NoSQL embedded data store for iOS, Android and .Net Mobile Platforms. In an earlier tutorial, we explored the basics of Database and Document CRUD operations using Couchbase Lite within your Android apps.
In addition to the standard CRUD operations, Couchbase Lite brings powerful Query API with SQL-like semantics and Full-Text-Search (FTS) capabilities to the edge. While the previous tutorial discussed the use of a single instance of Couchbase Lite embedded within your apps, you can also have multiple local instances of Couchbase Lite!
We will explore a few additional capabilities of Couchbase Lite in a new tutorial that we introduce here.
Couchbase Lite Android App Tutorial
The tutorial walks you through an Android app that will demonstrate how you can bundle, load and use a prebuilt instance of Couchbase Lite.
In the previous tutorial, we had a single instance of Couchbase Lite embedded within the app. In this tutorial, we will have two instances of Couchbase Lite. The app is pre-loaded with common data held in one instance. It is available to all users on the device, while the second instance holds user-specific data.
There are several reasons why you may want to bundle your app with a prebuilt database. This is suited for data that does not change very often, reducing bandwidth when syncing from a remote server. This also improves the overall user experience by reducing the start-up time.
The tutorial also introduces you to the basics of the QueryBuilder
interface. We will use a simple pattern matching query example.
App Overview
We will be extending the “User Profile” app that we introduced in the Fundamentals Tutorial.
This version of the app does the following:
-
- Allows users to log in and create or update user profile information.
- As part of the user profile, users can now select a university from a list of possible options.
The list of matching universities is queried (using the new Query API) from a local prebuilt “University” Couchbase Lite database that is bundled in the app.
The user profile information is persisted as a document in the local Couchbase Lite database. So subsequently, when the user logs out and logs back in again, the profile information is loaded from the database.
Next Steps
At the end of the tutorial, you will understand how to use prebuilt Couchbase Lite databases within Android apps. You should also gain familiarity with the QueryBuilder
API and how you use it to build and execute queries against your local database.
Stay tuned for future tutorials that will extend this app to incorporate more functionality of Couchbase Mobile! If you have questions or feedback, please leave a comment below or reach me on Twitter @probablyrealrob or email me at robert.hedgpeth@couchbase.com. The Couchbase Forums are another good place to reach out with questions.