Saving Data on Android
Learn about different ways to save data on Android! Use SharedPreferences to store user-facing configuration, use Files to store complex data in the form of JSON or media files, and use the SQLite Open Helper database to store meaningful objects that you can create, read, update and delete. By Filip Babić.
3.2 (10) · 3 Reviews
This is part of the Android Data & Networking learning path. View path.
Who is this for?
All beginner and intermediate Android developers who are looking for ways to store their data locally, support offline mode, or to save data without having to use a remote server.
- Local Persistence
- File System
- Data Streams
- Internal Storage
- External Storage
- Media Files
- Scoped Storage
- Primary Keys
- SQLite Open Helper
- Database Migrations
Part 1: Store Data In Shared Preferences
Welcome to the Saving Data on Android course! Learn about the concepts of data persistence on Android, what each concept brings, and how they are different.
Set Up The Project
Explore the starter project you'll be working on in the course, and set up your developer environment.
Learn how to use Context objects from Android to create SharedPreferences that are private to your app.
Learn about the SharedPreferences editors, and how to use them to store data, using commit() and apply() functions.
Practice using SharedPreferences to add functions which read the data from Prefs and show it to the user.
Learn about local, activity-based preferences, which are unique to Activity classes, and cannot be accessed globally.
Review all the concepts you've learned about SharedPreferences and storing simple user-facing configuration options.
Part 2: Use The File System
Learn about the File System in Android, what Files are used for, data streams, and how to write or read Files.
Set up some of the basic file operations that will help you access and work with the File System.
Learn how to store data in Files, and how to translate data into JSON structures, using Gson.
Learn how to read files, and how to list out all the files in the root or parent directory.
Practice using Files by adding more operations to your FilesHelper, and by connecting them to the UI.
Use External Storage
Learn how to switch to the external storage, to be able to expose your files to other applications.
Learn about Scoped Storage, the new way of storing and securing files on Android, and how to migrate.
Review all the concepts you've learned so far, and prepare for the last part of the course, and using databases.
Part 3: Use SQLite Database
Learn about the last concept in data persistence in the course - databases. Learn what SQL is and how SQL databases are formed.
Set Up The Database
Prepare the basic files and operations for your SQLiteOpenHelper database, and future episodes.
Learn how to save data in the database, by using ContentValues and writable databases. Explore the data using DBBS.
Learn how to read data from the database, using cursors. Display the data in the UI.
Practice using the SQLiteOpenHelper and its functions, to add more queries to your database.
Migrate The Database
Learn what database migrations are, and how to use them to add columns to the database and change the schema.
Finish your database implementation, by adding the final database query, to update trips with locations.
Congrats on finishing the course! Review all the concepts you've learned so far, and learn about new courses and more content to watch, to expand your knowledge.