4.5.6. addTaggedSearch Method
The event handler in Fig. 4.21 calls MainActivity
method addTaggedSearch
(Fig. 4.23) to add a new search to savedSearches
or to modify an existing search.
111 // add new search to the save file, then refresh all Buttons112 private void addTaggedSearch(String query, String tag)113 {114 // get a SharedPreferences.Editor to store new tag/query pair 115 SharedPreferences.Editor preferencesEditor = savedSearches.edit();116 preferencesEditor.putString(tag, query); // store current search 117 preferencesEditor.apply(); // store the updated preferences 118 119 // if tag is new, add to and sort tags, then display updated list ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.