title: android sqlite and ListView
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6685027/good-tutorial-for-sqlite-and-listview">Good Tutorial for SQLite and ListView</a>  </p>
  </blockquote>
  
  
  
  <p>Is there an example on how to use <code>ListView</code> with <code>sqlite</code> to read all rows in table  at once 
  or what do i change in the cursor to make it read all the titles at once</p>
  
  <pre><code>   //---get all titles---
     db.open();
     Cursor c = db.getAllTitles();
     String text = "";
     if (c.moveToFirst())
     {
        do {          
            DisplayTitle(c, text);
        } while (c.moveToNext());
     }
     db.close();
  }
  
  public void DisplayTitle(Cursor c, String text)
  {
       ListView.setText("id: " + c.getString(0) + "\n" + 
           "ISBN: " + c.getString(1) + "\n" + 
           "TITLE: " + c.getString(2) + "\n" + 
           "PUBLISHER:  " + c.getString(3));
  } 
  
  //---retrieves all the titles---
  public Cursor getAllTitles() 
  {
     return db.query(DATABASE_TABLE, new String[] {
              KEY_ROWID, 
              KEY_ISBN,
              KEY_TITLE,
              KEY_PUBLISHER}, 
              null, null, null, null, null);
      }
  }
  </code></pre>