title: Adding Cart Items to the Database and retrieving
body: <p>I have three tables in mySQL namely user, restaurants, cartlist.</p>
  
  <p>here user table is for saving the user details.
  restaurant table is for saving the meal details, price and quantity.
  cartlist is to add the restaurant details.
  Now when the specific user login to the app, I want the cartlist items of specific user added to the list. but Im getting the details of whole users who added items to the cart.</p>
  
  <pre><code>show.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              String selectQuery = "SELECT * FROM restaurants";
              SQLiteDatabase database = DatabaseManager.getInstance().openDatabase();
              Cursor cursor = database.rawQuery(selectQuery, null);
  
              if (cursor.moveToFirst()) {
                  do {
                      ProductModel productModel = new ProductModel();
                      productModel.setID(Integer.parseInt(cursor.getString(0)));
  
                      productModel.setName(cursor.getString(1));
                      productModel.setMealname(cursor.getString(2));
                      productModel.setMealprice(cursor.getString(3));
                      productModel.setMealqty(cursor.getString(4));
  
                      products.add(productModel);
  
                  } while (cursor.moveToNext());
              }
  
              cursor.close();
              DatabaseManager.getInstance().closeDatabase();
  
              adapter = new ProductAdapter(ProductList.this, R.layout.activity_cartlistview, products);
              listview.setAdapter(adapter);
              adapter.notifyDataSetChanged();
          }
      });
  </code></pre>
  
  <p>Carttable:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_checkout);
  
      lv_checkout = findViewById(R.id.lv_checkout);
      tv_totalamount = findViewById(R.id.tv_totalamount);
      btn_checkouttopayment = findViewById(R.id.btn_checkouttopayment);
  
      String selectQuery = "SELECT * FROM carttable";
      SQLiteDatabase database = DatabaseManager.getInstance().openDatabase();
      Cursor cursor = database.rawQuery(selectQuery, null);
  
      if (cursor.moveToFirst()) {
          do {
              ProductModel productModel = new ProductModel();
              productModel.setID(Integer.parseInt(cursor.getString(0)));
  
              productModel.setName(cursor.getString(1));
              productModel.setMealname(cursor.getString(2));
              productModel.setMealprice(cursor.getString(3));
              productModel.setMealqty(cursor.getString(4));
              productModel.setMealtotal((Double.parseDouble(cursor.getString(3)) * Double.parseDouble(cursor.getString(4)) + ""));
  
              products.add(productModel);
  
          } while (cursor.moveToNext());
      }
  
      double totalPrices = 0;
  
      for (int i = 0; i &lt; products.size(); i++) {
  
          totalPrices += Double.parseDouble(products.get(i).getMealtotal());
      }
  
      tv_totalamount.setText("Total Amount to be Paid : " + totalPrices + "");
      cursor.close();
      DatabaseManager.getInstance().closeDatabase();
  
      adapter = new ProductAdapter(this, R.layout.activity_cartlistview, products);
      lv_checkout.setAdapter(adapter);
      adapter.notifyDataSetChanged();
  }
  </code></pre>
  
  <p>what are the changed to be done to the query? Let me knw guys.TIA!</p>