title: Android Studio: Display ArrayList of SQLite database rows using ListView
body: <p>I have an SQLite database and I want to display each ROW/Campsite using ListView.</p>
  
  <p>DBHandler method to return an ArrayList of Campsites:</p>
  
  <pre><code>public ArrayList&lt;Campsite&gt; getAllCampsites() {
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_CAMPSITES, null);
      ArrayList&lt;Campsite&gt; campsites = new ArrayList&lt;&gt;();
      Campsite campsite;
      if (cursor.getCount() &gt; 0) {
          for (int i = 0; i &lt; cursor.getCount(); i++) {
              cursor.moveToNext();
              campsite = new Campsite();
              campsite.setName(cursor.getString(1));
              campsite.setCity(cursor.getString(2));
              campsite.setFeature(cursor.getString(3));
              campsite.setFavorite(cursor.getString(4));
              campsite.setRating(cursor.getInt(5));
              campsite.setLatitude(cursor.getDouble(6));
              campsite.setLongitude(cursor.getDouble(7));
  
              campsites.add(campsite);
          }
      }
      cursor.close();
      db.close();
      return campsites;
  }
  </code></pre>
  
  <p>I have an activity called Browse which has the ListView in the layout file. I also have a browse_row_layout which has the layout for one row/campsite.</p>
  
  <p>So in Browse.java I need to create the adapter to show each campsite.
  Note: I am only showing 3 specific columns (name, city, feature) in the list view</p>
  
  <p>So I have the activity_browse layout file which has the actual ListView element and the browse_row_layout which represents 1 row of the database and has TextViews for only 3 of the columns.</p>
  
  <p>What I have so far:</p>
  
  <pre><code>import android.os.Bundle;
  import android.widget.ListView;
  import androidx.appcompat.app.AppCompatActivity;
  import java.util.ArrayList;
  
  public class Browse extends AppCompatActivity {
  
  ListView lvCampsites;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_browse);
  
      lvCampsites= findViewById(R.id.lvCampsites);
  
      DatabaseHandler db = new DatabaseHandler(this);
      ArrayList&lt;Campsite&gt; campsites = db.getAllCampsites();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>TLDR: How can I create an adapter to show each campsite from the campsite list which has each row of the database, using ListView. </p>