views:

31

answers:

1

Hi,

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

A: 

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

but try to check constraint against null before toString call.

mohammad shamsi
The problem was two-fold really. Firstly I didn't need both a FilterQueryProvider in my activity at all as I had subclassed the adapter. This is discussed further [here](http://groups.google.com/group/android-developers/msg/21a569c89291496c?pli=1). The other problem was that I hadn't opened the database connection in my adapter (AutocompleteAdadapter)
Stev_k