In this video, Annyce walks you through the starting application for the course. She describes the user interface, package structure and class contents.
- [Narrator] In the exercise files I've included a copy of the starting application in the 00_04 directory. This is a basic Android studio project. Let's open it up now from the welcome screen. I'm going to click on open an existing Android studio project and then I'll navigate to where I'll have the exercise files stored here on my desktop in the 00_04 directory and then start. From here, I can just click on the build.gradle file.
The first thing I want to do is move over to the project view to show you the structure of our application. As we expand the app folder and then java, you'll see that the main package is info.adavis.topsy.turvey. Topsy turvey is the name of a fictitious bakery that this application is designed for. I've created a file which will house our sample recipe data for this application. We can find that inside of the DB package and its called recipes data provider.
This is a simple Java class which adds three recipes to a list of recipes. We're going to be using this class in almost every video. Next, we want to take a look at the UI. This can be found inside of the features.recipes package. The recipes activity is the main activity class for this application. If we open it up you can see that it's a very basic activity. It just loads and displays a recycler view of recipes.
Let's take a look at the XML layout next. We can access that here, by clicking in the gutter, next to the class definition. And we're going to choose activity_recipes. Let's switch over to the text view. And we can close this panel so that we can get a better view of everything contained in our layout file. This is a typical XML layout for displaying items in a list. We start with apparent coordinator layout and then as you scroll down you can see our toolbar and then finally, our recycler view.
That's it, if I run the application right now, in my emulator, you'll see that nothing is displayed in the list yet. Let's do that now. However, as we go through the demonstrations in the course, we'll use this application as a basis for understanding how to manage a database in our android applications. Further, you'll notice that in certain videos my database is originally empty. That's because I mostly clear the applications data between videos so that I can start with a blank slate.
This is best while we're actively working on the final database structure. Now, let's get started with persisting our data on Android.
To begin, Annyce Davis reviews using the de facto data persistence solution available on Android: SQLite. She takes you through basic SQLite concepts—such as how to create a database wrapper and insert data into a table—as well as a few more advanced topics. Next, she covers working with Cupboard, an open-source project dedicated to simplifying your SQLite interactions. To wrap up, she dives into working with Realm, an object database solution designed with mobile devices in mind. Throughout the course, Annyce discusses establishing relationships between database tables, creating and running queries, as well as performing data migrations.
- Overview of SQLite
- Defining a database table's schema
- Exploring SQLite create table syntax
- Executing create table statements
- Inserting data with a foreign key relation
- Inspecting the database using a terminal
- Updating and deleting records
- Working with Cupboard
- Working with Realm