4.5.3. Fields of Class MainActivity

Figure 4.19 contains class MainActivity’s static and instance variables. The String constant SEARCHES (line 31) represents the name of the file that will store the searches on the device. Lines 33–34 declare EditTexts that we’ll use to access the queries and tags that the user enters. Line 35 declares the SharedPreferences instance variable savedSearches, which will be used to manipulate the key–value pairs representing the user’s saved searches. Line 36 declares the ArrayList<String> that will store the sorted tag names for the user’s searches. Line 37 declares the ArrayAdapter<String> that uses the contents of the ArrayList<String> as the source of the items displayed in MainActivity’s ListView.

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.