Join David Gassner for an in-depth discussion in this video Retrieving data from shared preferences, part of Building a Note-Taking App for Android (2013).
So far, I've added code to my data source class, that identifies where the data will…go, a shared preferences object and can update and remove items from shared…preferences. Now, I'll add code to retrieve all of the…notes, from my shared preferences object and return them from the data source…class. I'm working in a version of the project…called, retrieving data. And I've opened up the notes data source…class. And I'm going to modify the find all…method. The first step is to retrieve data from…the shared preferences object. And we'll do this using a method called…get all. It returns an object called a map.…
A map is an unordered data collection, where each item in the collection has a…key and a value. I'll type the word map and press control…space and select the map interface from Java.util.…Just as with the list, I'm being asked to identify the data types of the items in…the map. And now there are two values being asked…for. The first is going to be a string.…And what I'm saying is that each item is going to have a string based key.…
Like its companions, this course will take you through building a complete mobile app from scratch; but this installment uses the Android SDK and Java to get the job done. Author David Gassner shows you how to install the SDK and the Android Developer Toolkit, create a project, save data on a device, build and control screen layouts, and create action bars and icons that control navigation.
These three related courses will use the same assets to develop the same app. (See Building a Note-Taking App for iOS and Building a Note-Taking App for Windows Phone 8 and Windows Store for more information.) Compare and contrast the different steps and discover the similarities and differences!
- Previewing the note-taking app
- Creating virtual devices for testing
- Unique concepts in Android
- Creating the Eclipse project
- Using local data storage
- Adding and retrieving data with the Shared Preferences API
- Creating screen designs
- Creating and editing notes
- Supporting older versions of Android with ActionBarSherlock