1 page.title=Search Overview 2 @jd:body 3 4 <div id="qv-wrapper"> 5 <div id="qv"> 6 <h2>Topics</h2> 7 <ol> 8 <li><a href="search-dialog.html">Creating a Search Interface</a></li> 9 <li><a href="adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a></li> 10 <li><a href="adding-custom-suggestions.html">Adding Custom Suggestions</a></li> 11 </ol> 12 <h2>Reference</h2> 13 <ol> 14 <li><a href="searchable-config.html">Searchable Configuration</a></li> 15 </ol> 16 <h2>Related samples</h2> 17 <ol> 18 <li><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable 19 Dictionary</a></li> 20 </ol> 21 </div> 22 </div> 23 24 25 <p>Search is a core user feature on Android. Users should be able 26 to search any data that is available to them, whether the content is located on the device or 27 the Internet. To help create a consistent search experience for users, Android provides a 28 search framework that helps you implement search for your application.</p> 29 30 <div class="figure" style="width:250px"> 31 <img src="{@docRoot}images/search/search-suggest-custom.png" alt="" height="417" /> 32 <p class="img-caption"><strong>Figure 1.</strong> Screenshot of a search dialog with custom 33 search suggestions.</p> 34 </div> 35 36 <p>The search framework offers two modes of search input: a search dialog at the top of the 37 screen or a search widget ({@link android.widget.SearchView}) that you can embed in your activity 38 layout. In either case, the Android system will assist your search implementation by 39 delivering search queries to a specific activity that performs searchs. You can also enable either 40 the search dialog or widget to provide search suggestions as the user types. Figure 1 shows an 41 example of the search dialog with optional search suggestions.</p> 42 43 <p>Once you've set up either the search dialog or the search widget, you can:</p> 44 45 <ul> 46 <li>Enable voice search</li> 47 <li>Provide search suggestions based on recent user queries</li> 48 <li>Provide custom search suggestions that match actual results in your application data</li> 49 <li>Offer your application's search suggestions in the system-wide Quick Search Box</li> 50 </ul> 51 52 <p class="note"><strong>Note</strong>: The search framework does <em>not</em> provide APIs to 53 search your data. To perform a search, you need to use APIs appropriate for your data. For example, 54 if your data is stored in an SQLite database, you should use the {@link android.database.sqlite} 55 APIs to perform searches. 56 <br/><br/> 57 Also, there is no guarantee that a device provides a dedicated SEARCH button that invokes the 58 search interface in your application. When using the search dialog or a custom interface, you 59 must provide a search button in your UI that activates the search interface. For more 60 information, see <a href="search-dialog.html#InvokingTheSearchDialog">Invoking the search 61 dialog</a>.</p> 62 63 <p>The following documents show you how to use Android's framework to implement search:</p> 64 65 <dl> 66 <dt><strong><a href="search-dialog.html">Creating a Search Interface</a></strong></dt> 67 <dd>How to set up your application to use the search dialog or search widget. </dd> 68 <dt><strong><a href="adding-recent-query-suggestions.html">Adding Recent Query 69 Suggestions</a></strong></dt> 70 <dd>How to provide suggestions based on queries previously used.</dd> 71 <dt><strong><a href="adding-custom-suggestions.html">Adding Custom Suggestions</a></strong></dt> 72 <dd>How to provide suggestions based on custom data from your application and also offer them 73 in the system-wide Quick Search Box.</dd> 74 <dt><strong><a href="searchable-config.html">Searchable Configuration</a></strong></dt> 75 <dd>A reference document for the searchable configuration file (though the other 76 documents also discuss the configuration file in terms of specific behaviors).</dd> 77 </dl> 78 79 80 <h2>Protecting User Privacy</h2> 81 82 <p>When you implement search in your application, take steps to protect the user's 83 privacy. Many users consider their activities on the phone—including searches—to 84 be private information. To protect each user's privacy, you should abide by the following 85 principles:</p> 86 87 <ul> 88 <li><strong>Don't send personal information to servers, but if you must, do not log it.</strong> 89 <p>Personal information is any information that can personally identify your users, such as their 90 names, email addresses, billing information, or other data that can be reasonably linked to such 91 information. If your application implements search with the assistance of a server, avoid sending 92 personal information along with the search queries. For example, if you are searching for businesses 93 near a zip code, 94 you don't need to send the user ID as well; send only the zip code to the server. If you must 95 send the personal information, you should not log it. If you must log it, protect that data 96 very carefully and erase it as soon as possible.</p> 97 </li> 98 <li><strong>Provide users with a way to clear their search history.</strong> 99 <p>The search framework helps your application provide context-specific suggestions while the user 100 types. Sometimes these 101 suggestions are based on previous searches or other actions taken by the user in an earlier 102 session. A user might not wish for previous searches to be revealed to other device users, for 103 instance, if the user shares the device with a friend. If your application provides suggestions that 104 can reveal previous search activities, you should implement the ability for the user to clear the 105 search history. If you are using {@link android.provider.SearchRecentSuggestions}, you can simply 106 call the {@link android.provider.SearchRecentSuggestions#clearHistory()} method. If you are 107 implementing custom suggestions, you'll need to provide a similar "clear history" method in your 108 content provider that the user can execute.</p> 109 </li> 110 </ul> 111 112 113