Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
Take your Android programming skills to the next level with the Android built-in framework that enables local data management in text files and SQLite-based relational databases. This course shows you how to create datacentric apps for Android devices, using SQLite, Java, and the built-in android.database packages. Author David Gassner describes how to define shared preferences, work with JSON and XML files in internal and external data stores, and create new local SQLite databases.
So far in this course, I focused on two major ways of saving data locally in an Android app. I've described how to use shared preferences to store simple key value pairs and how to create and read files in internal and external storage and how to use particular formats such as JSON and XML that are really useful for storing structured but not strongly-typed data. You will find, however, that many Android apps need more power. You might need the ability to store strongly-typed data or the ability to have multiple tables that you can relate to each other at runtime.
For these purposes, there's nothing like a relational database. Fortunately, the Android SDK incorporates SQLite. SQLite is a very powerful third- party open source database engine. You can find out everything about the raw SQLite product at this website, www.sqlite.org, but everything you really need is included in the Android SDK, including all the libraries that make up the Android engine, all of the classes and interfaces you need to program with it, and all of the documentation.
The classes and interfaces you use in Android to work with SQLite are all in a single package, android.database.sqlite. You can find the documentation at this web page, developer.android.com and so on. Here are the important classes that we'll use when working with an SQLite database. The SQLite Database class represents a database file. Each SQLite database is stored as a single file on your Android persistent storage area.
You can add a file extension of .db if you like, but it's not required. When you create the database, you'll control the name of the file that contains the database, and it will be a single file, unlike some other databases that scatter information over multiple files. All of the other classes in this list will be used for various tasks. The SQLiteOpenHelper is a base class that you'll extend to manage your particular database, and then you'll use classes like SQLite Query and SQLite Statement to represent queries and SQL statements.
You'll use the cursor to loop through the results from a query and SQLite Query Builder to build and manage your queries, and when problems occur, they'll be exposed to you as SQLite exception or subclasses of that class. So in the remaining videos of this chapter and the one after this, I'll describe how to get started with SQLite, how to create your initial database, and then how to manage the database at runtime to contain strongly-typed relational data for your Android app.
There are currently no FAQs about Android SDK: Local Data Storage.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.