Error while getting data from db
<p>I'm trying to get data from my db. I've already 50-60 methods I use for do operations on my db and all of them work good. Today I've created another method... But it doesn't work! Idk maybe it's because I'm using 2 times the same cursor.. Idk... This is the code that generates the mistake:</p>

<pre><code>public ArrayList&lt;String&gt; getValueFromTab(String tipoGrafico){

    SQLiteDatabase sqlDB = null;
    Cursor data = null;
    String ascissa=null;
    String tabella=null;
    ArrayList&lt;String&gt;dati=new ArrayList&lt;String&gt;();

    try {
        sqlDB = openDataBase(SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        data=sqlDB.rawQuery("SELECT TABELLA, ASCISSA FROM cpm_analysis WHERE CATEGORIA='"+tipoGrafico+"' AND ABILITATO &lt;&gt;'no'", null);

        if(data.getCount()==0){
            data=null;
        }else{
            while(data.moveToNext()){
                tabella=data.getString(0);
                ascissa=data.getString(1);
            }
            data=null;
        }
        data=sqlDB.rawQuery("SELECT DISTINCT"+ascissa+" FROM "+tabella+"", null);

        if(data.getCount()==0){
            data=null;
        }else{
            while(data.moveToNext()){
                dati.add(data.getString(1));
            }
            data=null;
        }
        return dati;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally {
        if (data != null)
            data.close();
        if (sqlDB != null)
            sqlDB.close();
    }

    return null;

}
</code></pre>

<p>I'm taking an exception after the first rawquery(). </p>

<p>This is another method that works perfectly:</p>

<pre><code>    SQLiteDatabase sqlDB = null;
    Cursor data = null;

    try {
        sqlDB = openDataBase(SQLiteDatabase.NO_LOCALIZED_COLLATORS);
        String[] posizioni=new String[]{"Grafici UL", "Grafici UR", "Grafici DL", "Grafici DR"};
        String[] categorie=new String[posizioni.length];
        String categorieTemp="";
        for(int i=0; i&lt;posizioni.length; i++){
            data=sqlDB.rawQuery("SELECT CATEGORIA FROM cpm_analysis WHERE AREA_DISPLAY='"+posizioni[i]+"' AND ABILITATO &lt;&gt; 'no' ", null);
            if(data.getCount()==0){
                data=null;}

            else{   
            while(data.moveToNext()){
                categorieTemp=data.getString(0);
                categorie[i]=categorieTemp;
            }
            data=null;
            }
        }
        return categorie;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally {
        if (data != null)
            data.close();
        if (sqlDB != null)
            sqlDB.close();
    }

    return null;

}
</code></pre>

<p>Where is the mistake? Sorry for my bad english and thanks in advance</p>

<p>EDIT</p>

<p>please help me >.&lt; I'm going crazy...</p>

<p>RE-EDIT</p>

<p>Ok I resolved it. Idk why but I cant call this method from one activity, so I called it in the Activity before. It didn't open db.. Idk why @_@ Now it works... Ty at all :)</p>
