title: how to display the entire database table data into a TextView in android using SQLite
body: <p>my problem is that the only data that is being display in TextView is the last entire row of
  the table.</p>
  
  <p>so here is my code for getting the entire data from database table:</p>
  
  <pre><code>public List&lt;Person&gt; getAllPerson()
  {
      List&lt;Person&gt; personList = new ArrayList&lt;Person&gt;();
  
      //select query
      String selectQuery = "SELECT  * FROM " + DATABASE_TABLE;
  
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor cursor = db.rawQuery(selectQuery, null);
  
  
      for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext())
      {
           Person person = new Person();
              person.setId(Integer.parseInt(cursor.getString(0)));
              person.setName(cursor.getString(1));
              person.setHotness(cursor.getString(2));
              person.setAge(Integer.parseInt(cursor.getString(3)));
  
              // Adding person to list
              personList.add(person);
      }
  
      return personList;
  
  }
  </code></pre>
  
  <p>here is my code for displaying the table data into TextView:</p>
  
  <pre><code>  public class SQLiteView extends Activity
    {
  
  private TextView tv;
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.sqlview);
      tv = (TextView) findViewById(R.id.tvDBdisplay);
  
      DbHelper d = new DbHelper(this);
  
      List&lt;Person&gt; person = d.getAllPerson();
  
      for (Person p: person)
      {
          String data =p.getId() + " " + p.getName() + " " + p.getHotness() +      " " + p.getAge();
          tv.setText(data);
  
      }
  
     }    
    }
  </code></pre>