Quiero que los datos int del cursor me ayuden por favor

public Cursor ShowBarchartIncome(int yearChoose) {
    Cursor cur1=db.rawQuery("SELECT "+COLEXPENSE+" as _id,"+" SUM(PRICE) as price from "+EXPENSETABLE
    +" WHERE ("+YEAREX+" = "+2012+") AND ("+MONTHEX+" = 01) AND ("+TYPE+" = 'income')",new String [] {});
    return cur1;    
  }
public class BarGraph { 
    public Intent getIntent(Context context) {

        DBHelper.open();            
        int spn=editYEAR.getId();
        int e = Integer.valueOf(spn);
        c = DBHelper.ShowBarchartIncome(e);
        startManagingCursor(c);

        //data 1
        int[] y ={**c.getCount()**,443,443,456,234,123,342,134,123,645,234,274};
        CategorySeries series = new CategorySeries("รายรับ");
        for(int i=0;i<y.length;i++){
        series.add("Bar "+ (i+1),y[i]);     
    }
}

I can't get true data sum price it return 1 to int[] y ={c.getCount()}

How can I get data sum price in showbarchartincome if true data is 15000

preguntado el 02 de febrero de 12 a las 11:02

1 Respuestas

Try insead of new String [] {} just use null.

Cursor cur1=db.rawQuery("SELECT "+COLEXPENSE+" as _id,"+" SUM(PRICE) as price from "+EXPENSETABLE
            +" WHERE ("+YEAREX+" = "+2012+") AND ("+MONTHEX+" = 01) AND ("+TYPE+" = 'income')", null);

Actualizar:

To get data from the cursor you should add the following lines:

c.moveToFirst();
price = c.getInt(c.getColumnIndex("price"));

c.getCount() just show the number of returned records.

Respondido 02 Feb 12, 15:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.