title: Textwatcher in custom listview with SQLite database
body: <p>I want to add a filter in custom listview which is getting values from sqlite database. Is it possible to filter according to two value of textview? Please help me to add a filter query . If you have any text watcher example then please tell me.</p>
  
  <p>I have added a listview adapter in MainActivity.java</p>
  
  <pre><code>   lv = (ListView) findViewById(R.id.listView1);
      mydb = new DBHelper(this);
      Log.d("tag", mydb.listfromdb().toString());
      lv.setAdapter(new ViewAdapter(mydb.listfromdb()));
  </code></pre>
  
  <p>and   </p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
  
          if (convertView == null) {
              LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = mInflater.inflate(R.layout.list_item, null);
          }
          Listcollection o = collectionlist.get(position);
  
          if (o != null) {
              TextView idText = (TextView) convertView
                      .findViewById(R.id.lvid);
              TextView nameText = (TextView) convertView
                      .findViewById(R.id.lvname);
  
              TextView dateText = (TextView) convertView
                      .findViewById(R.id.lvdate);
              TextView phoneText = (TextView) convertView
                      .findViewById(R.id.lvjno);
  
              if (idText != null) {
                  idText.setText(Integer.toString(o.getId()));
              }
              if (nameText != null) {
                  nameText.setText("Name : "
                          + collectionlist.get(position).getName());
              }
              if (dateText != null) {
                  dateText.setText("Date of Complain : "
                          + collectionlist.get(position).getCdate());
              }
              if (phoneText != null) {
                  phoneText.setText("Job No.: "
                          + collectionlist.get(position).getType());
              }
          }
  
          return convertView;
      }
  </code></pre>
  
  <p>Here I am getting values from DBHelper.java</p>
  
  <pre><code>public ArrayList&lt;Listcollection&gt; listfromdb() {
      SQLiteDatabase db = this.getReadableDatabase();
      ArrayList&lt;Listcollection&gt; results = new ArrayList&lt;Listcollection&gt;();
  
      Cursor crs = db.rawQuery("select * from contacts", null);
      while (crs.moveToNext()) {
          Listcollection item = new Listcollection();
          item.setId(crs.getInt(crs.getColumnIndex(CONTACTS_COLUMN_ID)));
          item.setName(crs.getString(crs.getColumnIndex(C_NAME)));
          item.setCdate(crs.getString(crs.getColumnIndex(C_CDATE)));
         item.setType(crs.getString(crs.getColumnIndex(C_TYPE)));
          results.add(item);
      }
  
      db.close();
      return results;
  }
  </code></pre>
  
  <p>I have also included DBHelper.java after removing some methods.</p>
  
  <pre><code>public class DBHelper extends SQLiteOpenHelper {
  
  public static final String DATABASE_NAME = "MyDBName.db";
  public static final String CONTACTS_TABLE_NAME = "contacts";
  public static final String CONTACTS_COLUMN_ID = "id";
  public static final String C_NAME = "name";
  public static final String C_TYPE = "type";
  public static final String C_ADDRESS = "address";
  public static final String C_DATE = "sdate";
  public static final String C_PHONE = "phone";
  public static final String C_PNAME = "pname";
  public static final String C_MNO = "mno";
  public static final String C_CDATE = "cdate";
  public static final String C_DNAME = "dname";
  public static final String C_DPHONE = "dphone";
  public static final String C_TSCHARGE = "tscharge";
  public static final String C_DAMOUNT = "damount";
  public static final String C_FANDSOL = "fandsol";
  public static final String C_TRNO = "trno";
  public static final String C_TCRAMOUNT = "tcramount";
  
  
  private HashMap hp;
  
  public DBHelper(Context context) {
      super(context, DATABASE_NAME, null, 1);
  }
  
  public ArrayList&lt;Listcollection&gt; listfromdb() {
      SQLiteDatabase db = this.getReadableDatabase();
      ArrayList&lt;Listcollection&gt; results = new ArrayList&lt;Listcollection&gt;();
  
      Cursor crs = db.rawQuery("select * from contacts", null);
      while (crs.moveToNext()) {
          Listcollection item = new Listcollection();
          item.setId(crs.getInt(crs.getColumnIndex(CONTACTS_COLUMN_ID)));
          item.setName(crs.getString(crs.getColumnIndex(C_NAME)));
          item.setCdate(crs.getString(crs.getColumnIndex(C_CDATE)));
         item.setType(crs.getString(crs.getColumnIndex(C_TYPE)));
          results.add(item);
      }
  
      db.close();
      return results;
  }
  
   }
  </code></pre>