problems passing data to EditText Android

2

I'm having trouble loading data from a sqlite table and sending that data to the EditText, which I may be doing wrong, when I go to open the screen returns that message in the Cat log

11-03 06:43:30.721 14420-14420/routerbox.com.br.centraisdoassinante I/Choreographer: Skipped 52 frames!  The application may be doing too much work on its main thread.



package routerbox.com.br.centraisdoassinante;

import android.app.ProgressDialog;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.EditText;

import java.sql.SQLException;
import java.util.List;

import routerbox.com.br.centraisdoassinante.routerbox.com.br.centraisdoassinante.Dao.PessoaDao;
import routerbox.com.br.centraisdoassinante.routerbox.com.br.centraisdoassinante.models.Pessoa;

/**
 * Created by rodrigo on 01/11/16.
 */

public class DadosCadastrais extends AppCompatActivity {
     private EditText edtNome ;
     private EditText edtCnpjCpf ;
     private EditText edtRgIe ;
     private EditText edtCep;
     private EditText edtUf ;
     private EditText edtCidade;
     private EditText edtBairro ;
     private EditText edtEndereco;
     private EditText edtnumero ;
     private EditText edtComplemento;
     private EditText edtFoneComercial;
     private EditText edtFoneResidencial;
     private EditText edtFoneCelular;
     private  EditText edtEmail ;
     private PessoaDao pessoaDao;
     private Pessoa pessoa;
     ProgressDialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState)  {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dados_cadastrais);
    }

    public void carregarDados() throws SQLException {
            pessoa = pessoaDao.queryForId(1);
            edtNome= (EditText)findViewById(R.id.edtNome);
            edtNome.setText(pessoa.getNome());
    }

}
    
asked by anonymous 03.11.2016 / 14:55

1 answer

1

I solved the problem I was not passing the database connection, then when it was instantiated the same it created a new reference.

protected void onCreate(Bundle savedInstanceState)  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dados_cadastrais);
    databaseHelper = new DatabaseHelper(DadosCadastrais.this);

    new Thread(new Runnable() {
        @Override
        public void run() {

            try {
                pessoaDao = new PessoaDao(databaseHelper.getConnectionSource());
                pessoa= pessoaDao.queryForId(1);
                edtNome= (EditText) findViewById(R.id.edtNome);
                edtNome.setText(pessoa.getNome());

            } catch (SQLException e) {
                e.printStackTrace();
            }


        }
    }).start();




}
    
03.11.2016 / 19:20