Once you've inserted data into a database table, the next thing you normally want to do is to retrieve and display the data. Using a new version of the project called RetrieveData, learn how to define a new constant in the ItemsTable class which will be an array of strings. The array will contain one string for each column in the database table. The order in which you declare the column names will determine the order of columns when you return data from the database.
- [Narrator] Once you've inserted data into a database…table, the next thing you normally want to do is…to retrieve and display the data.…I'm working in a new version of the project…named retrieved data and I've refactored the code a bit.…I used to have all the code to…insert data in the main activity class.…I've moved that code into the data source class…into a method named seed database.…It's exactly the same code as before.…It checks to see whether there's any data…in the database table and if not, it adds all that data in.…
And this method is now called from the main…activities on create method right…after instantiating the data source class.…Now that I've store the data in the database,…I know want to retrieve the data from the…database for display instead of…using the original sample data.…In order to retrieve data, you could…use a raw SQL statement, but as I described previously,…that would involve a lot of code.…And many times you can use the convenience methods…of the database class to do the work for you.…
- Modeling data in POJO classes
- Customizing a ListView item display
- Displaying data in a RecyclerView
- Creating a custom array adapter
- Managing shared preferences with Java
- Creating and importing JSON data files
- Accessing SQLite from the command line
- Retrieving data with SQLite queries
Skill Level Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m Intermediate
Android App Development: RESTful Web Serviceswith David Gassner2h 25m Intermediate
1. Display Static Data
2. Store Data in Shared Preferences
About shared preferences4m 41s
3. Store Data in Text Files
4. Manage Relational Data with SQLite
Next steps1m 43s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.