Once you know how to create files, you can create and read structured data in those files by using one of the industry standard data formats: JSON and XML. The Android SDK includes a set of classes for reading and writing JSON-based text, but they’re a bit cumbersome. David prefers to use an external library named Gson, from Google. Learn how to add the Gson library as a dependency, and then how to generate and save a JSON string to a file in external storage.
- [Instructor] Once you know how…to create files on an Android device…you can create and read structured data files using one of…the industry standard data formats JSON and XML.…Of these two, JSON is by far more popular…in the world of Android…so that's the format I'm going to focus on.…The Android SDK includes a set of classes…for reading and writing JSON based text…but they're a bit cumbersome.…I prefer to use an external library named GSON from Google.…I'm working in a version of my project…now called export JSON.…
In this version of the project…I'm now back to using all of the data…but I've also added all the permissions…so I can read and write external files on the device.…The first time I run the app now…I'll be prompted to give permission…to allow the app to access files.…I'll click allow and then I'll be able…to import and export files after I've done some more coding.…I already have menu choices in place…for export and for import but they don't do anything yet.…
Now if I go to my MainActivity class…and I go to the OnOptionsItemSelected method…
- 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.