Code example for SearchableInfo

Methods: getSuggestAuthority, getSuggestPath, getSuggestSelection

0
        if (searchable == null) {
            return null; 
        } 
        if (mSuggestUriBase == null) {
 
            String authority = searchable.getSuggestAuthority();
            if (authority == null) {
                return null; 
            } 
 
            Uri.Builder uriBuilder = new Uri.Builder()
                    .scheme(ContentResolver.SCHEME_CONTENT)
                    .authority(authority);
 
            // if content path provided, insert it now 
            final String contentPath = searchable.getSuggestPath();
            if (contentPath != null) {
                uriBuilder.appendEncodedPath(contentPath);
            } 
 
            // append standard suggestion query path 
            uriBuilder.appendPath(SearchManager.SUGGEST_URI_PATH_QUERY);
            mSuggestUriBase = uriBuilder.build();
        } 
        return mSuggestUriBase;
    } 
 
    /** 
     * This is a copy of {@link SearchManager#getSuggestions(SearchableInfo, String)}. 
     */ 
    private Cursor getSuggestions(Context context, SearchableInfo searchable, String query,
            int queryLimit) {
 
        Uri base = getSuggestUriBase(searchable);
        if (base == null) return null;
        Uri.Builder uriBuilder = base.buildUpon();
 
        // get the query selection, may be null 
        String selection = searchable.getSuggestSelection();
        // inject query, either as selection args or inline 
        String[] selArgs = null;
        if (selection != null) {    // use selection if provided
            selArgs = new String[] { query };
        } else {                    // no selection, use REST pattern