android - SQL database, how can I make my code more efficient
<p>I'm running a SQL query in a Database helper class method to return all entries from "drugs" table </p>

<pre><code>list_all_drugs() {
  Cursor cursor = db.query("drugs", null , null, null, null, null, null);
  return cursor;
}
</code></pre>

<p>then in my activity I use the cursor data as the following :</p>

<pre><code>db = new DatabaseHelper(this);
    c = db.list_all_drugs();
    c.moveToFirst();
    while (!c.isAfterLast()) {
        viewDrug(c.getString(0),c.getString(1),c.getString(2),c.getString(3),c.getString(4),c.getString(5),c.getString(6),c.getString(7),c.getString(8),c.getString(9),c.getString(10),c.getString(11));
        c.moveToNext();
}
</code></pre>

<p>then I pass these parameters to the viewDrug() method to display list of drugs from the database. Every thing is working fine, but I find this method not the best practice (?) specially when I want to insert or delete a database column the whole code structure would fail and I would have to do much hard coding.</p>

<p>So, in short, is there a better approach to dynamically interact with database columns rather than calling them one by one using their indexes ? thanks.</p>