January 2017
Beginner to intermediate
624 pages
22h 42m
English
Your service will be polling for new results, so it will need to know what the last result fetched was. This is a perfect job for another SharedPreferences entry.
Update QueryPreferences to store the ID of the most recently fetched photo.
Listing 28.6 Adding recent ID preference constant (QueryPreferences.java)
public class QueryPreferences {
private static final String PREF_SEARCH_QUERY = "searchQuery";
private static final String PREF_LAST_RESULT_ID = "lastResultId";
public static String getStoredQuery(Context context) {
...
}
public static void setStoredQuery(Context context, String query) {
...
}
public static String getLastResultId(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context) ...Read now
Unlock full access