In this video learn how updates are performed using Realm. Annyce reviews the behavior for both managed and unmanaged objects.
- [Instructor] If you recall, Realm uses transactions…in order to create new records in the database.…In this example, we're creating a new user record…and setting the name to Amber.…If we wanted to update a user record,…we would similarly use a transaction.…The difference is that we would get a reference…to an existing Realm object,…and then we would simply set the desired new value.…In this code snippet, we do a query…for any given record in the user table.…
Once it's found, we set the name…of the returned user to Gladys.…So let's say we have the following records…before the update is performed.…Amber, Joe, and Gladys.…Then after the transaction is executed,…we would have the following.…Gladys, Joe, and Gladys.…Another way to update your Realm objects…is by using the insert or update method…and then passing in a Realm object.…Here, we've defined the user instance…outside of the scope of Realm.…
Thus, it's considered an unmanaged Realm object.…The outcome of this transaction is highly dependent…on whether or not the user's ID field is a primary key.…
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 59m 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?
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.