Android Programming: The Big Nerd Ranch Guide, 2nd Edition
by Bill Phillips, Chris Stewart, Brian Hardy, Kristin Marsicano
Simple Persistence with Shared Preferences
The last piece of functionality you need to add is to actually use the query entered in the SearchView when the search request is submitted.
In your app, there will only be one active query at a time.
That query should be persisted (remembered by the app) between restarts of the app (even after the user turns off the device).
You will achieve this by writing the query string to shared preferences.
Any time the user submits a query, you will first write the query to shared preferences, overwriting whatever query was there before.
When a search is executed against Flickr, you will pull the query string from shared preferences and use it as the value for the text parameter.
Shared preferences ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access