Getlong error in MatrixCursor while in suggestion search framework


I have just bought the 3rd version of the Big Nerd Ranch Android and I wanted to take advantage of this forum.
I have developed a ContentProvider for my suggestion search (my app is about songs and should return some song names after typing a few letters as a suggestion ; ex : “bri” should return “across the bridge”) but it fails like this under Android Studio

--------- beginning of crash

2018-12-21 11:35:06.953 31905-31905/ E/AndroidRuntime: FATAL EXCEPTION: main

Process:, PID: 31905

java.lang.NumberFormatException: For input string: "glo"
    at java.lang.Long.parseLong(
    at java.lang.Long.parseLong(
    at android.database.MatrixCursor.getLong(

I have a very simple matrixcursor for the columns required by the search framework given there is only the mandatory " _id" column in it

private static String matrixCursorColumns = {"_id"};

Here is the source code for some important lines and the query cursor

private static final int SEARCH_SUGGEST = 0;
private static final int SEARCH_SUGGESTIONS = 1;
private static final int SHORTCUT_REFRESH=1

private static final String AUTHORITY=“”;

static final Uri CONTENT_URI=Uri.parse( “content://”+AUTHORITY);
mUriMatcher = new UriMatcher( UriMatcher.NO_MATCH );

public Cursor query(@NonNull Uri uri, @Nullable String projection,
@Nullable String selection,
@Nullable String selectionArgs,
@Nullable String sortOrder) {
String query = uri.getLastPathSegment().toLowerCase();

    if (mUriMatcher.match(uri) == SEARCH_SUGGEST) {
            Log.i("DEBUG_Sea_Cont_Prov", "query: if match");
            //String query = uri.getLastPathSegment().toLowerCase();
            return getSearchResultsCursor(query);
    else {
        Log.i("DEBUG_Sea_Cont_Prov", "query: else");

    return null;

private MatrixCursor getSearchResultsCursor(String searchString){
                searchResults.addRow( createRow1(searchString) );
    Log.i("DEBUG_Sea_Cont_Prov", "getSearchResultsCursor: avant return: mRow:"+searchResults.toString());
    //for (int i = 0; i < searchResults.getCount(); i++) {
    //    Log.i("DEBUG_Sea_Cont_Prov", "searchResults :"+searchResults.getString( i ));

    return searchResults;    }

private Object[] createRow1(String query)
    Log.i("DEBUG_Sea_Cont_Prov", "Entree dans createRow1 avec query:"+query);
    //return columnValuesOfQuery(query,"query");
    return columnValuesOfQuery(query);

private Object[] columnValuesOfQuery(String query)
    Log.i("DEBUG_Sea_Cont_Prov", "Entree dans columnValuesOfQuery avec query:"+query);
    return new String[]

Even if I add another column (SUGGEST_COLUMN_TEXT_1), it fails the same way.
Do you have an idea ?
Why is the Getlong used for in the MatrixCursor ?

Thanks in advance.

Jean-michel, Nemours, France


My problem is solved.
Someone helped me and showed me that the matrixCursor I was sending back to the query method contained a first row of String type instead of the integer type requested by the search framework.
Thank you.