New Course: Saving Data on Android
Learn various ways to persist data in your app: SharedPreferences, saving data to files, using SQLite, and using the Room library from Google. By Joe Howard.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
New Course: Saving Data on Android
10 mins
It’s day 7 of the Android Avalanche: an event where we’ll be releasing new Android and Kotlin books, courses, and screencasts every day!
Today, we are releasing a brand new course: Saving Data on Android.
In this 32-video course by Joe Howard, you’ll learn how persist data on your Android apps between app restarts. Through a series of hands-on exercises and challenges, you’ll use SharedPreferences, read and write files to storage, save data using SQLite, and try out the new Room Library to save data!
Take a look at what’s inside:
Part 1: SharedPreferences
In part one, learn how save data using SharedPreferences.
Introduction: Find out what’s covered in our Saving Data on Android video tutorial series: SharedPrefences, saving to files, SQLite, and Room.
The Starter App: Download the starter app, build it in Android Studio, and review the existing app code. Review the Model-View-Presenter (MVP) and Repository patterns.
Getting SharedPrefs: Learn about use cases for SharedPreferences, see how to access the default SharedPreferences, and also see how to setup a custom SharedPreferences.
Reading and Writing SharedPrefs: Learn how to save data into SharedPreferences, and how to read the data back in.
Challenge: Reading and Writing SharedPrefs: Practice what you’ve learned so far to save data into SharedPreferences and then read the data back in.
SharedPrefs Repository: Switch from saving the app data from an in-memory repository into a repository backed by SharedPreferences. Learn about the limitations of SharedPreferences.
Challenge: SharedPrefs Repository: Practice some more with the Repository pattern by deleting data from the SharedPreferences repository.
Conclusion: Let’s review what you’ve covered on SharedPreferences and the Repository pattern in this first part on Saving Data on Android, and then discuss what’s next.
-
Introduction: Find out what’s covered in our Saving Data on Android video tutorial series: SharedPrefences, saving to files, SQLite, and Room.
-
The Starter App: Download the starter app, build it in Android Studio, and review the existing app code. Review the Model-View-Presenter (MVP) and Repository patterns.
-
Getting SharedPrefs: Learn about use cases for SharedPreferences, see how to access the default SharedPreferences, and also see how to setup a custom SharedPreferences.
-
Reading and Writing SharedPrefs: Learn how to save data into SharedPreferences, and how to read the data back in.
-
Challenge: Reading and Writing SharedPrefs: Practice what you’ve learned so far to save data into SharedPreferences and then read the data back in.
-
SharedPrefs Repository: Switch from saving the app data from an in-memory repository into a repository backed by SharedPreferences. Learn about the limitations of SharedPreferences.
-
Challenge: SharedPrefs Repository: Practice some more with the Repository pattern by deleting data from the SharedPreferences repository.
-
Conclusion: Let’s review what you’ve covered on SharedPreferences and the Repository pattern in this first part on Saving Data on Android, and then discuss what’s next.
Part 2: Saving to Files
In the second part, learn to read and write files to storage.
Introduction: We’ll survey various issues with writing files, including internal vs. external storage, permissions, thread concerns, and checking for disk space.
Writing to Internal Storage: Learn how to write files to internal storage. You’ll use Gson to convert the app data and peer into the Android file system using Device File Explorer.
Reading from Internal Storage: See how to read files from internal storage using the Java SDK FileInputStream and BufferedReader classes.
Challenge: Internal Storage: Practice what you’ve learned about saving to internal storage by safeguarding your app against read and write errors.
External Storage: Switch from using internal storage to external storage for saving the app data, and see how to use adb to pull files from a device.
Deleting Files: Update the FileRepository to delete files, using some of the helper functions you’ve already developed.
Challenge: Deleting Files: Finish the use of the FileRepository for saving app data by practicing what you’ve learned to delete files.
Conclusion: Let’s review what you learned in this part of the course about saving data into files, reading files, and deleting files, and then discuss what’s next.
-
Introduction: We’ll survey various issues with writing files, including internal vs. external storage, permissions, thread concerns, and checking for disk space.
-
Writing to Internal Storage: Learn how to write files to internal storage. You’ll use Gson to convert the app data and peer into the Android file system using Device File Explorer.
-
Reading from Internal Storage: See how to read files from internal storage using the Java SDK FileInputStream and BufferedReader classes.
-
Challenge: Internal Storage: Practice what you’ve learned about saving to internal storage by safeguarding your app against read and write errors.
-
External Storage: Switch from using internal storage to external storage for saving the app data, and see how to use adb to pull files from a device.
-
Deleting Files: Update the FileRepository to delete files, using some of the helper functions you’ve already developed.
-
Challenge: Deleting Files: Finish the use of the FileRepository for saving app data by practicing what you’ve learned to delete files.
-
Conclusion: Let’s review what you learned in this part of the course about saving data into files, reading files, and deleting files, and then discuss what’s next.
Part 3: SQLite
In part 3, you’ll learn how to save data using SQLite.
Introduction: You are introduced to SQLite and the concepts of relational databases, including tables, columns, keys, and relationships.
Creating a Database: Create a database schema and use SQLiteOpenHelper to create a basic database. See how to use sqlite3 at the command line to review the database schema.
Writing Data: Use ContentValues as a means of writing data into SQLite. See how to use sqlite3 at the command line to query the database.
Challenge: Writing Data: Practice what you’ve learned so far about SQLite and ContentValues to write data into the SQLite datbase.
Reading Data: Use Cursor and and its companion CursorWrapper to read data from the SQLite database and into model objects.
Deleting Data: See how to delete data from a SQLite database, and how to guard against SQL injection attacks in your SQL code.
Challenge: Deleting Data: Finish the use of the SQLiteRepository for saving app data by practicing what you’ve learned to delete files.
Database Migrations: Learn about using database versioning and database migrations to handle modifying your database schema after your app has shipped.
Conclusion: Let’s review what you learned about saving data in your app using SQLite, and then discuss what’s next.
-
Introduction: You are introduced to SQLite and the concepts of relational databases, including tables, columns, keys, and relationships.
-
Creating a Database: Create a database schema and use SQLiteOpenHelper to create a basic database. See how to use sqlite3 at the command line to review the database schema.
-
Writing Data: Use ContentValues as a means of writing data into SQLite. See how to use sqlite3 at the command line to query the database.
-
Challenge: Writing Data: Practice what you’ve learned so far about SQLite and ContentValues to write data into the SQLite datbase.
-
Reading Data: Use Cursor and and its companion CursorWrapper to read data from the SQLite database and into model objects.
-
Deleting Data: See how to delete data from a SQLite database, and how to guard against SQL injection attacks in your SQL code.
-
Challenge: Deleting Data: Finish the use of the SQLiteRepository for saving app data by practicing what you’ve learned to delete files.
-
Database Migrations: Learn about using database versioning and database migrations to handle modifying your database schema after your app has shipped.
-
Conclusion: Let’s review what you learned about saving data in your app using SQLite, and then discuss what’s next.