Learn how to insert data with a foreign key relationship into your SQLite database using the insert method from the SQLiteDatabase class.
- [Instructor] But what about our recipe's steps?…We need to make sure that those are inserted as well.…Let's go back to our data source class…and add a new method for inserting a recipe step.…So, we can close the logs here…and move back over to the data source class.…The create recipe step method is going to be…very similar to inserting a recipe record,…except for we're going to have a recipe ID…sent in as a parameter.…
This is so we know which recipe this…particular step belongs to in our database.…Therefore, it's perfectly okay for us to copy this method,…create recipe from line 36 to line 46,…and then we're going to paste it right underneath…on line 48.…Now, let's refactor this so that it will…insert recipe steps instead of recipes.…The first thing we want to do on line 48…is to rename this method to createRecipeStep.…
Next, we're going to change the parameter…from a Recipe to a RecipeStep,…and then we'll also rename the variable to recipeStep.…The next thing we want to do is include…a parameter for the recipe ID…
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
Skill Level Intermediate
Android App Development: Unit Testingwith James P White2h 58m Intermediate
1. SQLite Basics
2. SQLite Beyond the Basics
3. Working with Cupboard
4. Realm Basics
5. Realm Beyond the Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.