index.jd revision ec80d7f311b1a0899bb4caf5b380b07027e902d1
1page.title=Search
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">Using the Android Search Dialog</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. The search experience should be seamless and consistent across the entire
28system, which is why Android provides a search framework to help you provide users with
29a familiar search dialog and a great search experience.</p>
30
31<div class="figure" style="width:250px">
32<img src="{@docRoot}images/search/search-suggest-custom.png" alt="" height="417" />
33<p class="img-caption"><strong>Figure 1.</strong> Screenshot of a search dialog with custom
34search suggestions.</p>
35</div>
36
37<p>Android's search framework provides a user interface in which users can perform a search and
38an interaction layer that communicates with your application, so you don't have to build
39your own search Activity. Instead, a search dialog appears at the top of the screen at the user's
40command without interrupting the current Activity.</p>
41
42<p>The search framework manages the life of the search dialog. When users execute a search, the
43search framework passes the query text to your application so your application can perform a
44search. Figure 1 shows an example of the search dialog with optional search suggestions.</p>
45
46<p>Once your application is set up to use the search dialog, you can:</p>
47
48<ul>
49<li>Enable voice search</li>
50<li>Provide search suggestions based on recent user queries</li>
51<li>Provide custom search suggestions that match actual results in your application data</li>
52<li>Offer your application's search suggestions in the system-wide Quick Search Box</li>
53</ul>
54
55<p class="note"><strong>Note</strong>: The search framework does <em>not</em> provide APIs to
56search your data. To perform a search, you need to use APIs appropriate for your data. For example,
57if your data is stored in an SQLite database, you should use the {@link android.database.sqlite}
58APIs to perform searches.</p>
59
60<p>The following documents show you how to use the search dialog in your application:</p>
61
62<dl>
63  <dt><strong><a href="search-dialog.html">Using the Android Search Dialog</a></strong></dt>
64  <dd>How to set up your application to use the search dialog. </dd>
65  <dt><strong><a href="adding-recent-query-suggestions.html">Adding Recent Query
66Suggestions</a></strong></dt>
67  <dd>How to show suggestions based on queries previously used in the search dialog.</dd>
68  <dt><strong><a href="adding-custom-suggestions.html">Adding Custom Suggestions</a></strong></dt>
69  <dd>How to show suggestions based on custom data from your application and offer your suggestions
70in the system-wide Quick Search Box.</dd>
71  <dt><strong><a href="searchable-config.html">Searchable Configuration</a></strong></dt>
72  <dd>A reference for the searchable configuration file (though the other
73documents also discuss the configuration file in terms of specific behaviors).</dd>
74</dl>
75
76
77<h2>Protecting User Privacy</h2>
78
79<p>When you implement search in your application, take steps to protect the user's
80privacy. Many users consider their activities on the phone&mdash;including searches&mdash;to
81be private information. To protect each user's privacy, you should abide by the following
82principles:</p>
83
84<ul>
85<li><strong>Don't send personal information to servers, but if you must, do not log it.</strong>
86<p>Personal information is any information that can personally identify your users, such as their
87names, email addresses, billing information, or other data that can be reasonably linked to such
88information. If your application implements search with the assistance of a server, avoid sending
89personal information along with the search queries. For example, if you are searching for businesses
90near a zip code,
91you don't need to send the user ID as well; send only the zip code to the server. If you must
92send the personal information, you should not log it. If you must log it, protect that data
93very carefully and erase it as soon as possible.</p>
94</li>
95<li><strong>Provide the user with a way to clear their search history.</strong>
96<p>The search framework helps your application provide context-specific suggestions while the user
97types. Sometimes these
98suggestions are based on previous searches or other actions taken by the user in an earlier
99session. A user might not wish for previous searches to be revealed to other device users, for
100instance, if they share their phone with a friend. If your application provides suggestions that can
101reveal previous activities, you should implement the ability for the user to clear the search
102history. If you are using {@link android.provider.SearchRecentSuggestions}, you can simply call the
103{@link android.provider.SearchRecentSuggestions#clearHistory()} method. If you are implementing
104custom suggestions, you'll need to provide a similar "clear history" method in your provider that
105the user can execute.</p>
106</li>
107</ul>
108
109
110