i am new to android programming.i looking to make a question and answer application.in this application i fetch the data from the data base file as follows
public String makeatext(String My_database_table, int i) {
SQLiteDatabase myDB = getDatabase();
String results = new String();
Cursor cur = null;
try {
String firstColumn = "questions";
cur = myDB.query(true, My_database_table,
new String[] { firstColumn }, null, null, null, null, null,
null);
int iquestion = cur.getColumnIndex(firstColumn);
if (cur.moveToPosition(i)) {
results = results + cur.getString(iquestion) + "\n";
}
return results;
}
catch (Exception e) {e.printStackTrace();
Log.e("ERROR", "ERROR in Make test file :" + e.toString());
e.printStackTrace();
// TODO: handle exception
}finally{
cur.close();
}
return results;
}
and in my main activity class i am initializing random value as
Random questions;
questions = new Random();
int Rnumber;Rnumber=0;
Rnumber=questions.nextInt(3);
and after setting the random value i am calling the function as
String shoow = myDb.makeatext(levels, Rnumber);
now i am getting a question but .what i want is as every time user opens application i want to show random questions.how to do this any suggestions will be very good to me
thanks,
maddy
move line
to onCreate()
and
to onResume
Do You have only 3 questions????