1
public class MainActivity extends ActionBarActivity{
Conexao c = new Conexao();
public void tela(){
c.CriaBanco();
}
}
public class Conexao extends MainActivity{
String NomeBanco = "Cadastro";
SQLiteDatabase BancoDados = null;
public void CriaBanco(){
try{
BancoDados = openOrCreateDatabase(NomeBanco, MODE_WORLD_READABLE, null);
String SQL = "CREATE TABLE IF NOT EXIST tabCadastro ( _id INTEGER PRIMARY KEY, nome TEXT, telefone TEXT) ";
BancoDados.execSQL(SQL);
MensagemAlerta("Banco de Dados", "Banco Criado com Sucesso");
}catch(Exception erro){
MensagemAlerta("Erro Banco de Dados", "Não foi possivel criar o Banco" + erro);
}
finally {
BancoDados.close();
}
}
public void MensagemAlerta(String TituloAlerta, String MensagemAlerta){
AlertDialog.Builder Mensagem = new AlertDialog.Builder(MainActivity.this);
Mensagem.setTitle(TituloAlerta);
Mensagem.setMessage(MensagemAlerta);
Mensagem.setNeutralButton("Ok", null);
Mensagem.show();
}
}
When calling a class on android gives this error:
07-02 18:50:18.090 21687-21687/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
07-02 18:50:18.090 21687-21687/? E/android.os.Debug﹕ failed to load memtrack module: -2
07-02 18:50:18.160 21687-21695/? E/cutils-trace﹕ Error opening trace file: No such file or directory (2)
07-02 18:50:18.800 21703-21703/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
07-02 18:50:18.800 21703-21703/? E/android.os.Debug﹕ failed to load memtrack module: -2
07-02 18:50:21.450 21713-21713/? E/AndroidRuntime﹕ in writeCrashedAppName, pkgName :com.example.gabrielbonatto.oficial
07-02 18:50:22.070 21713-21713/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.gabrielbonatto.oficial, PID: 21713
java.lang.StackOverflowError
Post more of your code, only with this you can not know for sure what it is. But whatever it is, gives a
StackOverflowError
which is what happens when you have an infinite or very deep recursion. In particular, what was the class of Android you called? Called how? What is the classConexao
and the methodCriaBanco()
?– Victor Stafusa
edited the code
– Gabriel Santana Bonatto
What is the class
BancoDados
, the methodexecSQL(String)
and the classMensagemAlerta
? What isNomeBanco
?– Victor Stafusa
@Gabrielsantanabonatto would be interesting to rename the attributes and methods with the first lowercase letter to make it easier to read the code.
– Dener
Solving Stackoverflow is up to us :P
– user2692
When I first saw the question I thought it was a mistake on the site...
– RSinohara