title: Checking if ListView is empty
body: <p>I am using SQLITE to store, retrieve and delete the values added in the cart. And added a delete button for each row in a Custom Listview. </p>
  
  <p>So when the user taps the delete button on the specific row it will delete the data also in the table.</p>
  
  <p>My problem is that how would I be able to check if the listview is empty when the user deletes everything in the cart?</p>
  
  <p>Can someone point me to what should I be doing or using?  Thanks in Advance! :D</p>
  
  <p>this is my Cart Class:</p>
  
  <pre><code>  //CART LISTVIEW
  private ArrayList&lt;String&gt; orderid;
  private ArrayList&lt;String&gt; orderName;
  private ArrayList&lt;String&gt; orderSize;
  private ArrayList&lt;String&gt; orderQuantity;
  
  private cartDatabaseHelper db;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_cart);
  
      db = new cartDatabaseHelper(this);
  
      //CART LISTVIEW
      orderid = new ArrayList&lt;&gt;();
      orderName = new ArrayList&lt;&gt;();
      orderSize = new ArrayList&lt;&gt;();
      orderQuantity = new ArrayList&lt;&gt;();
  
      TextView textEmpty = (TextView) findViewById(R.id.textEmpty);
  
      Button btnCheckout = (Button) findViewById(R.id.btnCheckout);
  
      ListView listView = (ListView) findViewById(R.id.listView);
  
      //ListView listView1 = (ListView) findViewById(R.id.emptyView);
  
  
      final ListCartAdapter adapter = new ListCartAdapter(cart.this, orderid, orderName, orderSize, orderQuantity);
      listView.setAdapter(adapter);
  
  
      Cursor data = db.getListContents();
      data.moveToFirst();
  
      if(data.getCount() == 0){
          textEmpty.setVisibility(View.VISIBLE);
          btnCheckout.setVisibility(View.GONE);
      }
      else
      {
          textEmpty.setVisibility(View.GONE);
          btnCheckout.setVisibility(View.VISIBLE);
  
          data.moveToFirst();
          do{
              orderid.add(data.getString(0));
              orderName.add(data.getString(1));
              orderSize.add(data.getString(2));
              orderQuantity.add(data.getString(3));
          } while (data.moveToNext());
  
      }
      data.close();
  }
  
  
  @Override
  public void onBackPressed() {
      finish();
  }
  </code></pre>
  
  <p>and this is my Adapter Class:</p>
  
  <pre><code>public class ListCartAdapter extends BaseAdapter {
  
  
  private Context context;
  
  private ArrayList&lt;String&gt; orderid;
  private ArrayList&lt;String&gt; orderName;
  private ArrayList&lt;String&gt; orderSize;
  private ArrayList&lt;String&gt; orderQuantity;
  
  public ListCartAdapter(Context context, ArrayList&lt;String&gt; orderid, ArrayList&lt;String&gt; orderName, ArrayList&lt;String&gt; orderSize, ArrayList&lt;String&gt; orderQuantity){
      this.context = context;
      this.orderid = orderid;
      this.orderName = orderName;
      this.orderSize = orderSize;
      this.orderQuantity = orderQuantity;
  
  }
  
  @Override
  public int getCount() {
      return orderName.size();
  }
  
  @Override
  public Object getItem(int position) {
      return orderName.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      return 0;
  }
  
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
  
      final View listView;
      final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      listView = inflater.inflate(R.layout.cart_list_item, null);
  
      TextView number = (TextView) listView.findViewById(R.id.textID);
      TextView name = (TextView) listView.findViewById(R.id.textOrderName);
      TextView size = (TextView) listView.findViewById(R.id.textOrderSize);
      TextView quantity = (TextView) listView.findViewById(R.id.textOrderQuantity);
  
      ImageButton btnRemove = (ImageButton) listView.findViewById(R.id.btnRemove);
  
      number.setText(orderid.get(position));
      name.setText(orderName.get(position));
      size.setText(orderSize.get(position));
      quantity.setText(orderQuantity.get(position));
  
      final cartDatabaseHelper db = new cartDatabaseHelper(context);
  
  
     //BUTTON TO REMOVE ROW
     btnRemove.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(final View v) {
  
              new AlertDialog.Builder(context)
                      .setTitle("REMOVE" + " " + orderName.get(position) + " " + "FROM CART?")
                      .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int which) {
  
                                  db.removeSingleContact(orderid.get(position));
  
                                  orderName.remove(position);
                                  orderSize.remove(position);
                                  orderQuantity.remove(position);
                                  notifyDataSetChanged();
                          }
                      })
                      .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                          public void onClick(DialogInterface dialog, int which) {
  
                              dialog.dismiss();
                          }
                      })
                      .show();
          }
      });
      return listView;
  }
  </code></pre>