0
// Create Database. final Sqlitedatabase bankDados = openOrCreateDatabase("Table name", MODE_PRIVATE, null);
// Criar Tabela.
bancoDados.execSQL("CREATE TABLE IF NOT EXISTS questions(id INT(3),perguntas VARCHAR)");
// Inserir Dados. ( Crl+d para duplicar INSERT INTO ).
// bancoDados.execSQL("INSERT INTO questions(id,perguntas) VALUES (1,'Posso ser cromado 1')");
// bancoDados.execSQL("INSERT INTO questions(id,perguntas) VALUES (2,'Posso ser cromado 2')");
// Puxar os dados da Tabela.
bt_perguntar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Cursor cursor = bancoDados.rawQuery("" +
"SELECT perguntas " +
"FROM questions " +
"ORDER BY RANDOM() " +
"LIMIT 1;",
null);
int indicePerguntas = cursor.getColumnIndex("perguntas");
cursor.moveToFirst();
while (cursor != null){
text_pergunta.setText(cursor.getString(indicePerguntas));
cursor.moveToNext();
//Log.i("RESULTADO - Pergunta ",cursor.getString(indicePerguntas));
}
}
});
Log error.
Do not put the code in image. Then edit your question and enter the code in text.
– Andrei Coelho
Andrei found it simpler, I’m new here. Would it be so I could copy the code and test? and Get an answer?
– GuilDraco
Exact Guil! This way you also increase your chances of someone responding to you! Hug!
– Andrei Coelho