title: SearchView Filter Mode mode in a Listview is not working
body: <p>My main activity have a Listview and a Search View. A Listview shows all entries from database. It works properly (load all words/strings from my database). But the problem is with the  <code>SearchView</code>. It is not filtering in the Listview the strings/words when I'm typing a text. So, it happens nothing and I don't know why. </p>
  
  <p>Three classes below: The main activity, wordactivity and database. I need some help. I'm a newbie. </p>
  
  <p>BancoDictionary (Main Acitivity)    </p>
  
  <pre><code>public class BancoDictionary extends Activity  {
  
  public static final String PREFS_NAME = "MyPrefsFile1";
  
  
  ListView mListView;
  SearchView sv;
  
  
  ArrayAdapter&lt;WordDefinition&gt; adapter;
  
  
  ArrayList&lt;WordDefinition&gt; allWordDefinitions=new ArrayList&lt;WordDefinition&gt;();
  
  
  DictionaryDatabase DictionaryDatabase;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.main);
  
  
      mListView = (ListView) findViewById(R.id.list);
      sv = (SearchView) findViewById(R.id.searchView1);
  
      adapter =new ArrayAdapter&lt;WordDefinition&gt;(this, android.R.layout.simple_list_item_1, allWordDefinitions);
      mListView.setAdapter(adapter);
  
      sv.setOnQueryTextListener(new OnQueryTextListener() {
  
          @Override
          public boolean onQueryTextSubmit(String text) {
              // TODO Auto-generated method stub
              return false;
          }
  
          @Override
          public boolean onQueryTextChange(String text) {
  
  
              adapter.getFilter().filter(text);
              return false;
          }
      });
  
      mListView.setTextFilterEnabled(true);
  
  
  
      DictionaryDatabase=new DictionaryDatabase(this); 
      allWordDefinitions=DictionaryDatabase.getAllWords(); 
  
  
  
  
      Collections.sort(allWordDefinitions, new CustomComparator());   
      mListView.setAdapter(new BaseAdapter() {
  
          @Override
          public View getView(int position, View view, ViewGroup parent) {
              if (view==null) {
                  view=getLayoutInflater().inflate(R.layout.list_item, parent, false);
              }
              TextView textView=(TextView) view.findViewById(R.id.listItemTextView);
              textView.setText(allWordDefinitions.get(position).word);
  
              return view;
          }
  
          @Override
          public long getItemId(int arg0) {
              // TODO Auto-generated method stub
              return 0;
          }
  
          @Override
          public Object getItem(int arg0) {
              // TODO Auto-generated method stub
              return null;
          }
  
          @Override
          public int getCount() {
              // TODO Auto-generated method stub
              return allWordDefinitions.size();
          }
      });
  
      mListView.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View view, int position,
                  long arg3) {
              Intent intent =new Intent(BancoDictionary.this, WordDefinitionDetailActivity.class);
              intent.putExtra("word", allWordDefinitions.get(position).word);
              intent.putExtra("definition", allWordDefinitions.get(position).definition);
  
  
              startActivity(intent);
          }
      });
  
  
  }
  
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.main, menu);
           return super.onCreateOptionsMenu(menu);
  }
  
  
  
  public class CustomComparator implements Comparator&lt;WordDefinition&gt; { 
         @Override
         public int compare(WordDefinition p1, WordDefinition p2) {
            return p1.word.compareToIgnoreCase(p2.word);
         }
      }
  
  }
  </code></pre>
  
  <p>WordDefinition</p>
  
  <pre><code>public class WordDefinition {
  String word,definition;
  
  public WordDefinition(String word,ArrayList&lt;String&gt; alldefinition) {
      this.word=word;
  
      StringBuilder stringBuilder=new StringBuilder();
      for (String string : alldefinition) {
          stringBuilder.append(string);
      }       
      this.definition=stringBuilder.toString();
  
  }
  
  public WordDefinition(String word,String alldefinition) {
      this.word=word;     
      this.definition=alldefinition;
  
  }
  
  
    }
  </code></pre>
  
  <p>DictionaryDatabase</p>
  
  <pre><code>public class DictionaryDatabase {
  private static final String TAG = "DictionaryDatabase";
  
  public static final String KEY_WORD = SearchManager.SUGGEST_COLUMN_TEXT_1;
  public static final String KEY_DEFINITION = SearchManager.SUGGEST_COLUMN_TEXT_2;
  
  private static final String DATABASE_NAME = "dictionary";
  private static final String FTS_VIRTUAL_TABLE = "FTSdictionary";
  private static final int DATABASE_VERSION = 2;
  
  private final DictionaryOpenHelper mDatabaseOpenHelper;
  private static final HashMap&lt;String,String&gt; mColumnMap = buildColumnMap();
  
  public DictionaryDatabase(Context context) {
      mDatabaseOpenHelper = new DictionaryOpenHelper(context);
  }
  
  private static HashMap&lt;String,String&gt; buildColumnMap() {
      HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;();
      map.put(KEY_WORD, KEY_WORD);
      map.put(KEY_DEFINITION, KEY_DEFINITION);
      map.put(BaseColumns._ID, "rowid AS " +
              BaseColumns._ID);
      map.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID, "rowid AS " +
              SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID);
      map.put(SearchManager.SUGGEST_COLUMN_SHORTCUT_ID, "rowid AS " +
              SearchManager.SUGGEST_COLUMN_SHORTCUT_ID);
      return map;
  }
  
  
  
  
  public Cursor getWord(String rowId, String[] columns) {
      String selection = "rowid = ?";
      String[] selectionArgs = new String[] {rowId};
  
      return query(selection, selectionArgs, columns);
  
  }
  
  public Cursor getWordMatches(String query, String[] columns) {
      String selection = KEY_WORD + " MATCH ?";
      String[] selectionArgs = new String[] {query+"*"};
  
      return query(selection, selectionArgs, columns);
  
  }
  
  private Cursor query(String selection, String[] selectionArgs, String[] columns) {
  
      SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
      builder.setTables(FTS_VIRTUAL_TABLE);
      builder.setProjectionMap(mColumnMap);
  
      Cursor cursor = builder.query(mDatabaseOpenHelper.getReadableDatabase(),
              columns, selection, selectionArgs, null, null, KEY_WORD + " COLLATE NOCASE ASC");
  
      if (cursor == null) {
          return null;
      } else if (!cursor.moveToFirst()) {
          cursor.close();
          return null;
      }
      return cursor;
  }
  
  private static class DictionaryOpenHelper extends SQLiteOpenHelper {
  
      private final Context mHelperContext;
      private SQLiteDatabase mDatabase;
  
      private static final String FTS_TABLE_CREATE =
                  "CREATE VIRTUAL TABLE " + FTS_VIRTUAL_TABLE +
                  " USING fts3 (" +
                  KEY_WORD + ", " +
                  KEY_DEFINITION + ");";
  
  
  
      DictionaryOpenHelper(Context context) {
          super(context, DATABASE_NAME, null, DATABASE_VERSION);
          mHelperContext = context;
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          mDatabase = db;
          mDatabase.execSQL(FTS_TABLE_CREATE);
          loadDictionary();
      }
  
  
  
      private void loadDictionary() {
          new Thread(new Runnable() {
              public void run() {
                  try {
                      loadWords();
                  } catch (IOException e) {
                      throw new RuntimeException(e);
                  }
              }
          }).start();
      }
  
      private void loadWords() throws IOException {
          Log.d(TAG, "Loading words...");
          final Resources URL = mHelperContext.getResources();
          InputStream input = new URL("http://example.com.br/example.txt").openStream();
  
  
          BufferedReader reader = new BufferedReader(new InputStreamReader(input));
          try {
              String line;
              while ((line = reader.readLine()) != null) {
                  String[] strings = TextUtils.split(line, "//");
                  if (strings.length &lt; 2) continue;
                  long id = addWord(strings[0].trim(), strings[1].trim());
                  if (id &lt; 0) {
                      Log.e(TAG, "unable to add word: " + strings[0].trim());
                  }
              }
          } finally {
              reader.close();
          }
          Log.d(TAG, "DONE loading words.");
      }
  
  
      public long addWord(String word, String definition) {
          ContentValues initialValues = new ContentValues();
          initialValues.put(KEY_WORD, word);
          initialValues.put(KEY_DEFINITION, definition);
  
          return mDatabase.insert(FTS_VIRTUAL_TABLE, null, initialValues);
      }
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                  + newVersion + ", which will destroy all old data");
          db.execSQL("DROP TABLE IF EXISTS " + FTS_VIRTUAL_TABLE);
          onCreate(db);
      }
  }
  
  public long insertData(WordDefinition wordDefinition) {
      SQLiteDatabase database=mDatabaseOpenHelper.getWritableDatabase();
      ContentValues values=new ContentValues();
  
      values.put(KEY_WORD, wordDefinition.word);
      values.put(KEY_DEFINITION, wordDefinition.definition);
  
      return database.insert(FTS_VIRTUAL_TABLE, null, values);        
  
  }
  
     public long updateData(WordDefinition wordDefinition) {
      SQLiteDatabase database=mDatabaseOpenHelper.getWritableDatabase();
      ContentValues values=new ContentValues();
  
      values.put(KEY_WORD, wordDefinition.word);
      values.put(KEY_DEFINITION, wordDefinition.definition);
  
      return database.update(FTS_VIRTUAL_TABLE, values, KEY_WORD+" =?", new String[]{wordDefinition.word});   
  
  }
  
  public void deleteData(WordDefinition wordDefinition) {
      SQLiteDatabase database=mDatabaseOpenHelper.getWritableDatabase();
      String queryString="DELETE FROM "+FTS_VIRTUAL_TABLE+" WHERE "+KEY_WORD+" = '"+wordDefinition.word+"'";
  
      database.execSQL(queryString);
  }
  
  
  public ArrayList&lt;WordDefinition&gt; getAllWords() {
  ArrayList&lt;WordDefinition&gt; arrayList=new ArrayList&lt;WordDefinition&gt;();
  SQLiteDatabase database=mDatabaseOpenHelper.getReadableDatabase();
  
  String selectAllQueryString="SELECT * FROM "+FTS_VIRTUAL_TABLE;
  Cursor cursor=database.rawQuery(selectAllQueryString, null);
  
  if (cursor.moveToFirst()) {
      do {            
          WordDefinition wordDefinition=new WordDefinition(cursor.getString(cursor.getColumnIndex(KEY_WORD)), cursor.getString(cursor.getColumnIndex(KEY_DEFINITION)));
          arrayList.add(wordDefinition);              
      } while (cursor.moveToNext());          
  }   
  return arrayList;
  }
  
  public WordDefinition getWordDefinition(String word) {
  SQLiteDatabase database=mDatabaseOpenHelper.getReadableDatabase();
  WordDefinition wordDefinition=null;
  
  String selectQueryString="SELECT * FROM "+FTS_VIRTUAL_TABLE+ " WHERE "+KEY_WORD+" = '"+word+ "'";
  Cursor cursor=database.rawQuery(selectQueryString, null);
  
  if (cursor.moveToFirst()) {
      wordDefinition=new WordDefinition(cursor.getString(cursor.getColumnIndex(KEY_WORD)), cursor.getString(cursor.getColumnIndex(KEY_DEFINITION)));
  
  }   
  
  return wordDefinition;
  
  }
  
  public WordDefinition getWordDefinition(long id) {
  SQLiteDatabase database=mDatabaseOpenHelper.getReadableDatabase();
  WordDefinition wordDefinition=null;
  
  String selectQueryString="SELECT * FROM "+FTS_VIRTUAL_TABLE+ " WHERE "+BaseColumns._ID+" = '"+id+ "'";
  Cursor cursor=database.rawQuery(selectQueryString, null);
  
  if (cursor.moveToFirst()) {
      wordDefinition=new WordDefinition(cursor.getString(cursor.getColumnIndex(KEY_WORD)), cursor.getString(cursor.getColumnIndex(KEY_DEFINITION)));
  
  }   
  
  return wordDefinition;
  
     }
  
  
   public void initializeDatabaseFortheFirstTime(ArrayList&lt;WordDefinition&gt; wordDefinitions) {
  SQLiteDatabase database=mDatabaseOpenHelper.getWritableDatabase();
  database.execSQL("BEGIN");
  
  ContentValues contentValues=new ContentValues();
  
  for (WordDefinition wordDefinition : wordDefinitions) {
      contentValues.put(KEY_WORD, wordDefinition.word);
      contentValues.put(KEY_DEFINITION, wordDefinition.definition);           
      database.insert(FTS_VIRTUAL_TABLE, null, contentValues);
  }
  database.execSQL("COMMIT");
  
  }
  
    }
  </code></pre>