1page.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
19Dictionary</a></li>
20</ol>
21</div>
22</div>
23
24
25<p>Search is a core user feature on Android. Users should be able
26to search any data that is available to them, whether the content is located on the device or
27the Internet. To help create a consistent search experience for users, Android provides a
28search 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
33search suggestions.</p>
34</div>
35
36<p>The search framework offers two modes of search input: a search dialog at the top of the
37screen or a search widget ({@link android.widget.SearchView}) that you can embed in your activity
38layout. In either case, the Android system will assist your search implementation by
39delivering search queries to a specific activity that performs searchs. You can also enable either
40the search dialog or widget to provide search suggestions as the user types. Figure 1 shows an
41example 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
53search your data. To perform a search, you need to use APIs appropriate for your data. For example,
54if your data is stored in an SQLite database, you should use the {@link android.database.sqlite}
55APIs to perform searches.
56<br/><br/>
57Also, there is no guarantee that a device provides a dedicated SEARCH button that invokes the
58search interface in your application. When using the search dialog or a custom interface, you
59must provide a search button in your UI that activates the search interface. For more
60information, see <a href="search-dialog.html#InvokingTheSearchDialog">Invoking the search
61dialog</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
69Suggestions</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
73in 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
76documents 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
83privacy. Many users consider their activities on the phone&mdash;including searches&mdash;to
84be private information. To protect each user's privacy, you should abide by the following
85principles:</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
90names, email addresses, billing information, or other data that can be reasonably linked to such
91information. If your application implements search with the assistance of a server, avoid sending
92personal information along with the search queries. For example, if you are searching for businesses
93near a zip code,
94you don't need to send the user ID as well; send only the zip code to the server. If you must
95send the personal information, you should not log it. If you must log it, protect that data
96very 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
100types. Sometimes these
101suggestions are based on previous searches or other actions taken by the user in an earlier
102session. A user might not wish for previous searches to be revealed to other device users, for
103instance, if the user shares the device with a friend. If your application provides suggestions that
104can reveal previous search activities, you should implement the ability for the user to clear the
105search history. If you are using {@link android.provider.SearchRecentSuggestions}, you can simply
106call the {@link android.provider.SearchRecentSuggestions#clearHistory()} method. If you are
107implementing custom suggestions, you'll need to provide a similar "clear history" method in your
108content provider that the user can execute.</p>
109</li>
110</ul>
111
112
113