Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Null Pointer Exception during PerformFiltering on an AutoCompleteTextView

I have successfully implemented a custom SimpleCursorAdapter for an AutoCompleteTextView, which suggests entries from the database according to what has been entered into the box. However, I am getting the following non-fatal errors:

An exception occured during performFiltering()!
java.lang.NullPointerException
at com.stev.LondonTaxi.Route.runQuery(Route.java:456) at com.stev.LondonTaxi.AutocompleteAdapter.runQueryOnBackgroundThread(AutocompleteAdapter.java:61)

Relevant extracts from my code are below - I wonder if anyone might be able to shed any light?

public class Route extends Activity implements View.OnClickListener,
AdapterView.OnItemClickListener, FilterQueryProvider {

from_adapt.setFilterQueryProvider(this);

public Cursor runQuery(CharSequence constraint) {
String filter = constraint.toString().toUpperCase() + "%'"; 
Cursor all_Cursor_filter = dbse.autocomplete_query(filter);
return all_Cursor_filter;
     }

public class AutocompleteAdapter extends SimpleCursorAdapter implements Filterable {
 public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
    if (getFilterQueryProvider() != null) 
    { return getFilterQueryProvider().runQuery(constraint); }
    return dbAdapt.autocomplete_query();
        }

Steve

like image 391
Stev_k Avatar asked Mar 09 '26 06:03

Stev_k


1 Answers

either constraint or dbse is null. not sure line 456 is which one.

but try to check constraint against null before toString call.

like image 169
mhshams Avatar answered Mar 11 '26 21:03

mhshams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!