We help IT Professionals succeed at work.
Get Started

How to return a DataPoint from a Method , I need a help on that issue

Khan Consultoria
Last Modified: 2020-01-13
Hello Guys

I am working with DataPoint variable and my problem is being when I need to create a method ( function ) that can result a dataPoint.

I created a method this way:

public DataPoint[] GeraGraficoEstudoMes(String Situacao, String idTema){

        int i=0;

        String wSql = " SELECT strftime(''%d'',data) AS DIA,  Count(1) AS TOTAL_ACERTO  FROM CRTGRAFICOESTUDO " +
                      " WHERE ACERTOU='" + Situacao + "'" +
                      "   AND strftime(''%Y'',data)=strftime(''%Y'',''now'') " +
                      "   AND strftime(''%m'',data)=strftime(''%m'',''now'') ";

        if (!idTema.isEmpty()) {
            wSql = wSql + " AND TAB_TEMA_ID=" + idTema;

        wSql = wSql + " GROUP BY strftime(''%d'',data) ";
        wSql = wSql + " ORDER BY strftime(''%d'',data) ";

        Cursor cs = mSQSqLiteDatabase.rawQuery(wSql, null);

        DataPoint[] points = new DataPoint[cs.getCount()];

        if (cs.getCount() > 0) {

            if (cs.moveToFirst()) {
                while (!cs.isAfterLast()) {
                    points[i] = new DataPoint(cs.getInt(0), cs.getInt(1));


        return points;

Open in new window

something is wrong when I try to get the result, that way:

DataPoint[] points1 = DB.GeraGraficoEstudoMes("A", "");

I am not sure how to work around with that, I am newbier in Java and Android studio

I appreciate a lot your help with some simple example

Watch Question
Senior Developer
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE