Error when I want to display a row from sqlite
<p>In my app I want to display data from sqlite. 
When I press the button Show Info, I want to put the records that returns function getInfo in the textView. This is my code:</p>

<pre><code>btnShow = (Button) findViewById(R.id.btnInfo);
        final TextView txtNume = (TextView) findViewById(R.id.txtNume);
        final TextView txtPrenume = (TextView) findViewById(R.id.txtPrenume);
        final TextView txtTelefon = (TextView) findViewById(R.id.txtTelefon);
        final TextView txtAdresa = (TextView) findViewById(R.id.txtadresa);
        final TextView txtAdresaEmail = (TextView) findViewById(R.id.txtEmail);
        final TextView txtDataNasterii = (TextView) findViewById(R.id.txtDataNasterii);
        final TextView txtSex = (TextView) findViewById(R.id.txtSex);
        btnShow.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                Pacienti pacienti = pacientiDB.getInfo(text);
                if (pacienti != null) {
                    pacienti.setTelefon(txtTelefon.getText().toString());
                    pacienti.setPrenume(txtPrenume.getText().toString());
                    pacienti.setNume(txtNume.getText().toString());
                    pacienti.setAdresa(txtAdresa.getText().toString());
                    pacienti.setDataNasterii(txtDataNasterii.getText().toString());
                    pacienti.setEmail(txtAdresaEmail.getText().toString());
                    pacienti.setSex(txtSex.getText().toString());
                    }}

});
</code></pre>

<p>This is the function getInfo:</p>

<pre><code>public Pacienti getInfo(String text) {
        Pacienti returnPacient = null;
        Cursor cursor = null;

        try {

            cursor = database.rawQuery("SELECT * FROM " + PACIENTI_NAME
                    + " WHERE prenume = '" + text + "'", null);
            if (cursor.getCount() &gt; 0) {
                int indexTelefon = cursor.getColumnIndex("telefon");
                int indexPrenume = cursor.getColumnIndex("prenume");
                int indexNume = cursor.getColumnIndex("nume");
                int indexAdresaEmail = cursor.getColumnIndex("adresaEmail");
                int indexSex = cursor.getColumnIndex("Sex");
                int indexAdresaBuletin = cursor.getColumnIndex("AdresaBuletin");
                int indexDatanasterii = cursor.getColumnIndex("dataNasterii");
                cursor.moveToFirst();
                do {
                    String nume = cursor.getString(indexNume);
                    String prenume = cursor.getString(indexPrenume);
                    String Telefon = cursor.getString(indexTelefon);
                    String AdresaEmail = cursor.getString(indexAdresaEmail);
                    String Sex = cursor.getString(indexSex);
                    String AdresaBuletin = cursor.getString(indexAdresaBuletin);
                    String DataNasterii = cursor.getString(indexDatanasterii);

                    returnPacient = new Pacienti();
                    returnPacient.setNume(nume);
                    returnPacient.setPrenume(prenume);
                    returnPacient.setTelefon(Telefon);
                    returnPacient.setAdresa(AdresaBuletin);
                    returnPacient.setEmail(AdresaEmail);
                    returnPacient.setDataNasterii(DataNasterii);
                    returnPacient.setSex(Sex);
                    cursor.moveToNext();

                } while (!cursor.isAfterLast());
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }

        return returnPacient;
    }
</code></pre>

<p>But it didn't work. I receive this error and I don't understand why, because I verify that I have data in the database:</p>

<pre><code>04-14 10:35:33.478: E/AndroidRuntime(278): FATAL EXCEPTION: main
04-14 10:35:33.478: E/AndroidRuntime(278): java.lang.NullPointerException
04-14 10:35:33.478: E/AndroidRuntime(278):  at com.example.medicaldoi.ShowInfo$1.onClick(ShowInfo.java:53)
04-14 10:35:33.478: E/AndroidRuntime(278):  at android.view.View.performClick(View.java:2408)
04-14 10:35:33.478: E/AndroidRuntime(278):  at android.view.View$PerformClick.run(View.java:8816)
04-14 10:35:33.478: E/AndroidRuntime(278):  at android.os.Handler.handleCallback(Handler.java:587)
04-14 10:35:33.478: E/AndroidRuntime(278):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-14 10:35:33.478: E/AndroidRuntime(278):  at android.os.Looper.loop(Looper.java:123)
04-14 10:35:33.478: E/AndroidRuntime(278):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-14 10:35:33.478: E/AndroidRuntime(278):  at java.lang.reflect.Method.invokeNative(Native Method)
04-14 10:35:33.478: E/AndroidRuntime(278):  at java.lang.reflect.Method.invoke(Method.java:521)
04-14 10:35:33.478: E/AndroidRuntime(278):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-14 10:35:33.478: E/AndroidRuntime(278):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-14 10:35:33.478: E/AndroidRuntime(278):  at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Can someone help me please!</p>
