page.title=Search @jd:body

Topics

  1. Using the Android Search Dialog
  2. Adding Recent Query Suggestions
  3. Adding Custom Suggestions

Reference

  1. Searchable Configuration

Related samples

  1. Searchable Dictionary

Search is a core user feature on Android. Users should be able to search any data that is available to them, whether the content is located on the device or the Internet. The search experience should be seamless and consistent across the entire system, which is why Android provides a search framework to help you provide users with a familiar search dialog and a great search experience.

Figure 1. Screenshot of a search dialog with custom search suggestions.

Android's search framework provides a user interface in which users can perform a search and an interaction layer that communicates with your application, so you don't have to build your own search Activity. Instead, a search dialog appears at the top of the screen at the user's command without interrupting the current Activity.

The search framework manages the life of the search dialog. When users execute a search, the search framework passes the query text to your application so your application can perform a search. Figure 1 shows an example of the search dialog with optional search suggestions.

Once your application is set up to use the search dialog, you can:

Note: The search framework does not provide APIs to search your data. To perform a search, you need to use APIs appropriate for your data. For example, if your data is stored in an SQLite database, you should use the {@link android.database.sqlite} APIs to perform searches.

The following documents show you how to use the search dialog in your application:

Using the Android Search Dialog
How to set up your application to use the search dialog.
Adding Recent Query Suggestions
How to show suggestions based on queries previously used in the search dialog.
Adding Custom Suggestions
How to show suggestions based on custom data from your application and offer your suggestions in the system-wide Quick Search Box.
Searchable Configuration
A reference for the searchable configuration file (though the other documents also discuss the configuration file in terms of specific behaviors).

Protecting User Privacy

When you implement search in your application, take steps to protect the user's privacy. Many users consider their activities on the phone—including searches—to be private information. To protect each user's privacy, you should abide by the following principles: