title: Android - load values from sqlite database to an arraylist
body: <p>I am new to android . I have an application working with SQLite DB.
  I need to push values from  database to an arraylist of type object.
  The code i used is given here.</p>
  
  <pre><code> private ArrayList&lt;objectname&gt; objectList  = new ArrayList&lt;objectname&gt;();
   //function used to get values from database
     public ArrayList&lt;objectname&gt; getResults() {
  
      MyDb db = new MyDb(this); //my database helper file
      db.open();
      Cursor c = db.getAllValues(); //function to retrieve all values from a table- written in MyDb.java file
      if (c.moveToFirst())
      {
          do {         
              String date = c.getString(c.getColumnIndex("date"));
  
              try
              {
                  ob = new objectname();
                  ob.setDate(c.getString(c.getColumnIndex("date")));// setDate function is written in Class file
                  objectList.add(ob);
              }
              catch (Exception e) {
               Log.e(MY_DEBUG_TAG, "Error " + e.toString());
              }
  
           } while (c.moveToNext());
      }
         db.close();
         return objectList;
  }
  </code></pre>
  
  <p>This is not working correctly. Not shown any errors but i didn't get values in to the arraylist objectList</p>
  
  <p>Please help me..Thanks in advance..</p>