title: How to display the array in reverse order in Android
body: <p>Hi I have created a database and displayed the contents in list view. I need to display the contents from last to first record. Here is my code:</p>
  
  <pre><code>Cursor c = db.rawQuery("select * from TABLE", null);
  
  String[] array = new String[c.getCount()];
  int i = c.getCount();
  if (c.moveToLast())
  {
      do 
      {
          String uname = c.getString(c.getColumnIndex("product_name"));               
          array[i] = uname;
          i--;
      }
      while (c.moveToPrevious()) ;
  }
  </code></pre>
  
  <p>I have stored the column "product_name " in a string array. In order to print the column in reverse order this is the code I have tried. Application stopped unfortunately. Can anyone say where did I go wrong?</p>