title: SearchView show Result from SQLITE database to ListView
body: <p>i want to run a search on a activity where a custom list is showing me the records of medicine. I haven't worked on <code>SearchView</code>.</p>
  
  <p>My Medicine Database Code :</p>
  
  <pre><code>package com.example.sarhanaashir.wecare.Database_MedInfo;
  
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.util.Log;
  
  import java.util.ArrayList;
  
  
  public class DatabaseHelperMed extends SQLiteOpenHelper
  
  {
      private static final String Database_Name = "WeCareDatabaseMed";
      private static final int Database_Ver = 1;
  
      public DatabaseHelperMed(Context context, String name, SQLiteDatabase.CursorFactory factory, int version)
      {
          super(context,Database_Name,null,Database_Ver);
      }
  
      @Override
      public void onCreate(SQLiteDatabase sqLiteDatabase)
      {
          String query = "CREATE TABLE tbl_med(id INTEGER PRIMARY KEY AUTOINCREMENT,MedName TEXT,MedSymptom TEXT)";
          sqLiteDatabase.execSQL(query);
      }
  
  
      @Override
      public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1)
      {
          sqLiteDatabase.execSQL("DROP TABLE IF EXISTS tbl_med");
          this.onCreate(sqLiteDatabase);
      }
  
      public boolean addNewMedicine(MedicineRecord med_rec)
      {
          SQLiteDatabase db = this.getWritableDatabase();
          ContentValues values = new ContentValues();
  
          values.put("MedName", med_rec.getMed_name() );
          values.put("MedSymptom", med_rec.getMed_sym() );
  
          db.insert("tbl_med", null, values);
          db.close();
  
          return true;
      }
  
      public ArrayList&lt;MedicineRecord&gt; getAllMed()
      {
          SQLiteDatabase db = this.getReadableDatabase();
          ArrayList&lt;MedicineRecord&gt; medi = new ArrayList&lt;&gt;();
          Cursor cursor = db.rawQuery("select * from tbl_med", null);
          if (cursor.moveToFirst())
          {
  
              while (!cursor.isAfterLast())
              {
                  String id = cursor.getString(0);
                  String name = cursor.getString(1);
                  String sympt = cursor.getString(2);
  
                  medi.add(new MedicineRecord(name,sympt));
                  cursor.moveToNext();
  
              }
          }
          return medi;
      }
      public Cursor searchTasks(SQLiteDatabase db, String searchTxt)
  
      {
          Cursor cursor;
          String q = "select * tbl_med from  where MedSymptom Like '"+searchTxt+"%'";
          cursor = db.rawQuery(q,null);
          return cursor;
      }
  }
  </code></pre>
  
  <p>My Activity Where <code>SearchView</code> is :</p>
  
  <pre><code> package com.example.sarhanaashir.wecare.Database_MedInfo;
  
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  
  import android.view.View;
  import android.widget.Button;
  import android.widget.ListView;
  import android.app.SearchManager;
  import android.widget.SearchView;
  import android.widget.SearchView.OnQueryTextListener;
  
  import com.example.sarhanaashir.wecare.R;
  
  import java.util.ArrayList;
  
  public class Med_info extends AppCompatActivity {
  
      private ArrayList&lt;MedicineRecord&gt; med_record;
      private MedicineListAdapter adapter;
      private ListView listView;
      DatabaseHelperMed db;
      SearchView searchView1;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_med_info);
  
          inti();
  
          searchView1 = (SearchView) findViewById(R.id.SVscrhMed);
  
          searchView1.setOnQueryTextListener(new OnQueryTextListener()
          {
              @Override
              public boolean onQueryTextSubmit(String qry)
              {
                  return false;
              }
  
              @Override
              public boolean onQueryTextChange(String newText)
  
              {
                  return true;
              }
          });
      }
  
      private void inti()
      {
          db = new DatabaseHelperMed(Med_info.this,"WeCareDatabaseMed.db",null,1);
          med_record = new ArrayList&lt;&gt;();
          listView = (ListView) findViewById(R.id.Med_list);
          adapter = new MedicineListAdapter(this, R.layout.med_rec_style, med_record);
          listView.setAdapter(adapter);
  
          fillmed();
  
      }
  
      private void fillmed()
      {
          med_record.clear();
          med_record.addAll(db.getAllMed()); // Getting Medicine from database.
          adapter.notifyDataSetChanged();
      }
  }
  </code></pre>
  
  <p>My Medicine Records are perfectly showing in my Custom List, the only thing i want is to put a searchView so that user can search the medicine from the list.</p>