-4

I am making an Android app for automatic generation of question paper. In which I've made a database where I've stored questions but I'm facing problem in generating ramdon questions so that questions don't get repeated in the same question paper. Is there any specific function to generate random question from question set?

Benjith Mathew
  • 1,211
  • 1
  • 11
  • 23
  • For more details read information given below - what you mean. – Sree Jan 08 '18 at 04:34
  • I am making an Android app for automatic generation of question paper. In which I've made a database where I've stored questions but I'm facing problem in generating ramdon questions so that questions don't get repeated in the same question paper. Is there any specific function to generate random question from question set? – HRISHIKESH KEDAR Jan 08 '18 at 04:36

1 Answers1

1

You can use Random keyword for order by and limit the number of record you want.

 Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " ORDER BY RANDOM() LIMIT " + limit, null);
   // use the cursor data

If you have data in List use below link https://stackoverflow.com/a/4229001/8603832

MJM
  • 5,119
  • 5
  • 27
  • 53