title: sqlite database updating Gridview when searching with a searchview
body: <p>i was able to create a database and fill it with some foods !! and display them in a gridview  take a look <a href="https://i.stack.imgur.com/pQLGW.png" rel="nofollow noreferrer">screenshot of my app</a></p>
  
  <p>i want to know how i can make the search view work so that when i search for a food the gridview gets updated too !!!</p>
  
  <p>the second problem is : i implemented OnItemClickListener for each subitem in the gridview </p>
  
  <p>public class FoodList extends AppCompatActivity {</p>
  
  <pre><code>GridView gridView;
  static ArrayList&lt;Food&gt; list;
  FoodListAdapter adapter = null;
  SearchView sv;
  
  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.food_list_activity);
  
      gridView = (GridView) findViewById(R.id.gridView);
  
      list = new ArrayList&lt;&gt;();
      adapter = new FoodListAdapter(this, R.layout.food_items, list);
      gridView.setAdapter(adapter);
  
     // get all data from sqlite
     Cursor cursor = MainActivity.sqLiteHelper.getData("SELECT * FROM FOOD ");
      list.clear();
      while (cursor.moveToNext()){
          int id = cursor.getInt(0);
          String name = cursor.getString(1);
          String price = cursor.getString(2);
          byte[] image = cursor.getBlob(3);
  
          list.add(new Food(name, price, image, id));
      }
     adapter.notifyDataSetChanged();
  
  
      gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
  
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Food food = list.get(position);
              Intent i = new Intent(FoodList.this,Details.class);
              i.putExtra("position", position);
              Bundle bundle = new Bundle();
  
              startActivity(i);
          }
      });
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>but this wont work when i add the searchview !! because the positions of the subitems will change and it wont return the right position when</p>
  
  <p>Food food = list.get(position);</p>
  
  <p>here is the activity that i am starting when subitems are clicked</p>
  
  <pre><code>public class Details extends AppCompatActivity {
   int position;
  Button b;
  EditText edi;
  ImageView im;
  TextView text;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_details);
  
      b=(Button)findViewById(R.id.hotelbu);
      edi=(EditText)findViewById(R.id.hoteled);
      im = (ImageView)findViewById(R.id.hotelim);
      text=(TextView)findViewById(R.id.hoteltx);
  
      if(getIntent().getExtras() != null) {
          position = getIntent().getExtras().getInt("position", 0);
      }
  
      switch(position){
  
          case 9999:
  
  
  
              break;
          default:
  
              text.setText(FoodList.list.get(position).getName());
              edi.setText(FoodList.list.get(position).getPrice());
              break;
      }
  }
  }
  </code></pre>
  
  <p>i hope you guys understand what i am looking for , sorry for my bad english , any help is appreciated Thank you </p>