My activity of an Android application has this code.
public class gerenciar2 extends ActionBarActivity{
boolean editar=false, adcionar=false, remover=false;
SQLiteDatabase Banco = null;
Cursor cursor;
String tabbanco="Tabela1";
TextView gerenciar;
ListView lista;
String tabelas[];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gerenciamento);
lista = ( ListView ) findViewById(R.id.list);
abrebanco();
buscardados();
gerelista();
}
public void gerelista() {
cursor.moveToLast();
int x=cursor.getCount();
int y=1;
while(y<x){
//nextdado();
tabelas[x]=retornadado();
dadoanterior();
y++;
};
//return tabelas;
}
public boolean dadoanterior() {
try{
cursor.moveToPrevious();
return true;
}
catch(Exception erro){
return false;
}
}
public boolean buscardados(){
try{
cursor = Banco.query("tabela",
new String [] {"tabelas",}
, null, null, null, null, null);
if (cursor.getCount() != 0){
cursor.moveToFirst();
}else{
String sql = "INSERT INTO tabela (tabelas) " +
"values (Tabela1) ";
Banco.execSQL(sql);
}
return true;
}
catch(Exception erro){
Exibirmensagem("BANCO", "erro ao buscar no banco: "+ erro.getMessage(), "ok");
return false;
}
}
public String retornadado(){
String dado = cursor.getString(cursor.getColumnIndex("tabelas"));
return dado;
}
public void abrebanco(){
try{
Banco = openOrCreateDatabase("banco", MODE_WORLD_WRITEABLE, null);
String sql ="CREATE TABLE IF NOT EXISTS tabela (ID INTEGER PRIMARY KEY" +
", tabelas TEXT)";
Banco.execSQL(sql);
}
catch(Exception erro){
Exibirmensagem("BANCO", "erro ao criar banco: =/"+ erro.getMessage(), "ok");
}
}
The error "no Intent" is in this line:
tabelas[x]=retornadado();
If I comment on this line the activity wheel.
I am treating the array in the wrong way?