This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Learn about what the Room library is and what we'll be doing with it!
Project Files
Recommended SQL Learning
- To really get the hang of Room, you'll need to have a pretty good understanding of SQL.
- Take the first four courses in the Beginner SQL Track to get up to speed.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
[MUSIC]
0:00
Hi, I'm Ben and in this course we'll
be talking about data persistence.
0:09
Data persistence is just a fancy
way to say saving data, and
0:14
in Android there's a few
different ways to save data.
0:17
In the Activity Lifecycle course,
we learned how to save an activity state
0:20
using bundles and how to store key
value pairs using shared preferences.
0:25
These are both examples
of data persistence.
0:29
But they're only useful when you
need to store key value pairs,
0:31
like whether the user prefers
the dark theme or the light theme.
0:35
If you need to store some more complicated
data, you'll want to use a database.
0:39
Setting up a database on Android
used to be a lot more complicated.
0:43
But recently,
Android's released the Room Library and
0:46
it makes working with
databases a lot easier.
0:50
If you've not yet worked with databases or
you're not yet familiar with SQL,
0:53
now's a good time to get started.
0:57
Check out the teacher's notes below for a
recommended course to get you up to speed.
0:59
I won't say it's required, but having
a good understanding of databases and
1:03
how to query them with SQL will
make it a lot easier to focus
1:08
on learning the Android side of things.
1:11
In addition to learning about Room, we'll
also see how to use the new view model
1:13
class, as well as how to use the live data
to make our UI update automatically based
1:18
on what's in our database.
1:23
To get practice with persisting data,
1:25
we'll be adding a database
to an already existing app.
1:27
You can find a link to the app
in the teacher's notes below.
1:30
Take a second to download and build the
app, and keep in mind that most libraries
1:33
will probably have been updated between
me making this video and you watching it.
1:38
So you may have to update some version
numbers in your build.gradle file.
1:43
Once you've got the app, we'll go
over how it works in the next video.
1:47
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up