Example usage for android.app SearchManager SUGGEST_PARAMETER_LIMIT

List of usage examples for android.app SearchManager SUGGEST_PARAMETER_LIMIT

Introduction

In this page you can find the example usage for android.app SearchManager SUGGEST_PARAMETER_LIMIT.

Prototype

String SUGGEST_PARAMETER_LIMIT

To view the source code for android.app SearchManager SUGGEST_PARAMETER_LIMIT.

Click Source Link

Document

Query parameter added to suggestion queries to limit the number of suggestions returned.

Usage

From source file:cm.aptoide.com.actionbarsherlock.widget.SuggestionsAdapter.java

public Cursor getSuggestions(String query, int limit) {
    Uri.Builder uriBuilder = new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel()
            .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel()

    // append standard suggestion query path
    uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);

    // inject query, either as selection args or inline
    uriBuilder.appendPath(query);/*from   www. java2s .co  m*/

    if (limit > 0) {
        uriBuilder.appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT, String.valueOf(limit));
    }

    Uri uri = uriBuilder.build();

    // finally, make the query
    return mContext.getContentResolver().query(uri, null, null, null, null);
}