troubleshooting Question

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

Avatar of Khan Consultoria
Khan ConsultoriaFlag for Brazil asked on
JavaAndroid
4 Comments1 Solution110 ViewsLast Modified:
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) ";


        openDataBase();
        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));
                    cs.moveToNext();
                }
            }
        }

        cs.close();
        closeDataBase();

        return points;
    }

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

Regards
Alex
ASKER CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros