Skip to content Skip to sidebar Skip to footer

Limiting The Number Of Search Suggestions, Android

Is there a way to limit the number of displayed suggestions, when using the search interface with custom search suggestion? Thanks!

Solution 1:

It's very simple actually.

Firstly in your ContentProvider, define a variable to have a reference to:

publicstaticfinalStringLIMIT_PARAMETER="LIMIT";

In your Cursor query @Override of the provider define something to hold your limit value

String limit = uri.getQueryParameter(LIMIT_PARAMETER);

Then pass the limit to the SqliteQueryBuilder:

finalCursorcursor= queryBuilder.query(db, projection, selection,
        selectionArgs, null, null, sortOrder, limit);

You can then use it with a contentResolver like so:

getContentResolver().query( 
    SOME_CONTENT_URI.buildUpon().appendQueryParameter(
        YourContentProvider.LIMIT_PARAMETER, yourLimit).build(), 
    mSuggestionProjection, mSelection,
    filterArgArray, ORDER_BY );

Post a Comment for "Limiting The Number Of Search Suggestions, Android"