title: Refresh a ListView with a cursor with new data from DB
body: <p>I have a problem refreshing a ListView. I call my <code>ListView</code> <code>Activity</code>, I get the data from DB with a SQL statment with a cursor, I draw the <code>ListView</code> with a custom adapter (extends <code>BaseAdapter</code>), all works fine.</p>
  
  <p>I want to put an <code>EditText</code> on the top to search items on my <code>ListView</code>, filter the actual view, same Activity, with the typed text. I <code>getText()</code> from <code>EditText</code>, and make a new SQL statment filtering the results with this text. I have checked that the cursor has the correct filtered results, but I use <code>adapter.notifyDataSetChanged()</code> trying to update the <code>ListView</code> but nothing happens (no errors or force closes).</p>
  
  <p>Can anyone help me or tell me some tips to obtain this simple search function working with a database? I have found many similar questions with <code>ArrayLists + getFilter() + SimpleCursorAdapter</code>, but it doesn't works with my DB and custom adapter.</p>
  
  <p><strong>Activity</strong> ListaCaracteres:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(es.hsk.ap.R.layout.lista_caracteres);
  
      try{
          hanyuDBHelper = new HanyuSQLHelper(this);
          hanyuDB = hanyuDBHelper.getReadableDatabase();
          c = hanyuDB.rawQuery(" SELECT * FROM Caracteres ", null);
      }
      catch(SQLiteException ex)
      {
          Toast mensajeError=Toast.makeText(getApplicationContext(), "Error accediendo a los datos", Toast.LENGTH_SHORT);
          mensajeError.show();
          Log.e("LogLugares", "Error en getReadableDatabase()", ex);
      }
  
  
      adapter = new AdapterListaCaracteres(this,c);
      listaCaracteres = (ListView)findViewById(es.hsk.ap.R.id.listaCaracteres);
      listaCaracteres.setAdapter(adapter);
  
      buscador = (EditText)findViewById(R.id.buscador);
      buscador.addTextChangedListener(new TextWatcher()
      {
          @Override
          public void onTextChanged( CharSequence arg0, int arg1, int arg2, int arg3)
          {
          }
  
          @Override
          public void beforeTextChanged( CharSequence arg0, int arg1, int arg2, int arg3)
          {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable arg0)
          {
              // TODO Auto-generated method stub
  
              String texto="";
              texto=buscador.getText().toString();
  
              c = hanyuDB.rawQuery(" SELECT * FROM Caracteres WHERE significado LIKE '%"+texto+"%'", null);
              adapter.notifyDataSetChanged();
          }
      });
  }
  </code></pre>
  
  <p>My <strong>custom adapter</strong>, AdapterListaCaracteres extends from BaseAdapter:</p>
  
  <pre><code>public class AdapterListaCaracteres extends BaseAdapter implements ListAdapter{
  
  private Context  mContext;
  private Cursor  datos;
  private LayoutInflater inflater;
  
  public AdapterListaCaracteres(Context  context, Cursor  c){
      this.mContext = context;
      this.datos = c;
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return datos.getCount();
  }
  
  @Override
  public Object  getItem(int position) {
      // TODO Auto-generated method stub
      return datos.getString(position);
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
  }
  
  public View  getView(int position, View  convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
  
      View item = convertView;
      ViewHolder holder;
  
      inflater = (LayoutInflater) mContext.getSystemService(Context .LAYOUT_INFLATER_SERVICE);
      datos.moveToPosition(position);
  
      if(item==null){
          try{
              item = inflater.inflate(es.hsk.ap.R.layout.caracter, null);
          }
          catch(InflateException ex)
          {
  
          }
  
  
          holder = new ViewHolder();
          holder.caracter = (TextView)item.findViewById(es.hsk.ap.R.id.caracter);
          holder.pinyin = (TextView)item.findViewById(es.hsk.ap.R.id.pinyin);
          holder.significado = (TextView)item.findViewById(es.hsk.ap.R.id.significado);
  
          item.setTag(holder);
      }
      else{
          holder = (ViewHolder)item.getTag();
      }           
  
      holder.caracter.setText(datos.getString(2));            
      holder.pinyin.setText(datos.getString(3));  
      holder.significado.setText(datos.getString(4));
  
      return item;
  
  }
  static class ViewHolder{
      TextView caracter;
      TextView pinyin;
      TextView significado;
  }
  }
  </code></pre>