Note that there are some explanatory texts on larger screens.

plurals
  1. PORetrieving date from SQLite database via cursor
    primarykey
    data
    text
    <p>Iam trying to plot a graph with achartengine where I need an array of dates fetched from tthe database so that I can use it with TimeSeries. However Iam unable to retrieve the dates from the database with a cursor. Kindly help</p> <pre><code>heres my code:- public Date[] getReportDates(ReportGraph reportGraph) { // TODO Auto-generated method stub String [] columns = new String[]{KEY_ROW_ID, KEY_KM, KEY_FUEL_QTY, KEY_FUEL_PRICE, KEY_TOTAL_COST, KEY_MILEAGE, KEY_DATE,KEY_TANK_FULL}; String selectQuery = "SELECT _date FROM fuel_table"; reportCursor = ourDatabase.rawQuery(selectQuery, null); Date[] reportList=null ; int i = 0; int count = reportCursor.getCount(); reportList = new Date[count]; if(reportCursor.moveToFirst()) { do { reportList[i] = (Date)reportCursor.getLong(0); // ERROR here i++; }while(reportCursor.moveToNext()); } reportCursor.close(); return reportList; } code for line chart:- double[] fPrice; double[] fMileage; Date[] fDates; XYMultipleSeriesRenderer rRenderer; XYMultipleSeriesDataset dataset; XYSeriesRenderer priceRenderer, mileageRenderer,dateRenderer; public Intent getIntent(Context context) { FuelStoredInfo reportInfo =new FuelStoredInfo(context); reportInfo.open(); fPrice=reportInfo.getReportData(this); fMileage = reportInfo.getReportMileage(this); fDates = reportInfo.getReportDates(this); reportInfo.close(); TimeSeries fPriceseries = new TimeSeries("Fuel prices"); for(int i=0;i&lt;fDates.length;i++) { fPriceseries.add(fDates[i], fPrice[i]); } TimeSeries fMileageSeries = new TimeSeries("Mileage"); for(int i=0;i&lt;fDates.length;i++) { fMileageSeries.add(fDates[i],fMileage[i]); } // Our second data dataset = new XYMultipleSeriesDataset(); dataset.addSeries(fPriceseries); dataset.addSeries(fMileageSeries); </code></pre> <p><img src="https://i.stack.imgur.com/rVvYq.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload