title: store data from sqlite into array to draw line graph, Android
body: <p>i'm retrieving data from the table in sqlite. The table store, date and value which i store as datetime. the data i want to retrieve and put it into two different array. one array for date, and one more for the value.. the data is dynamic.. means it can be add some more.. </p>
  
  <p>below is my code.</p>
  
  <pre><code> private XYMultipleSeriesDataset getDemoDataset() {
  
      DBHelper helper = new DBHelper(this);
      database = helper.getReadableDatabase();
  
      Cursor c = database.rawQuery("select * from " + DBHelper.TABLE_GLUCOSE, null);
  
      //double[] seriesFirstY = {20,-20,67,180,-45,24,99,-34,-8};
      double[] seriesSecondY = {10,80,-40,-20,135,24,199,-34,80};
  
      XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
      XYSeries firstSeries = new XYSeries("Ideal Reading");
  
      while (!c.isAfterLast()) {
          int date = c.getInt((Integer) c.getColumnIndexOrThrow(DBHelper.GLUCOSE_DATE));
          int bbData = c.getInt((Integer) c.getColumnIndexOrThrow(DBHelper.BBDATA));
          firstSeries.add(bbData, date);
          c.moveToNext();
      }
      dataset.addSeries(firstSeries);
  
      c.close();
  
      /*XYSeries firstSeries = new XYSeries("Ideal Reading");
      for (int i = 0; i &lt; myArray.length; i++)
          firstSeries.add(i, mStringArray[i]);
      dataset.addSeries(firstSeries);*/
  
      XYSeries secondSeries = new XYSeries("Your Reading");
      for (int j = 0; j &lt; 9; j++)
          secondSeries.add(j, seriesSecondY[j]);
      dataset.addSeries(secondSeries);
      return dataset;
  }
  </code></pre>
  
  <p>and i got java.lang.nullpointer at </p>
  
  <pre><code>android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:203)
   android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
   android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
  android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:158)
  </code></pre>