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?
问问题
51 次
1 回答
1
您可以使用 Random 关键字进行排序和limit
所需的记录数。
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_NAME + " ORDER BY RANDOM() LIMIT " + limit, null);
// use the cursor data
如果您在列表中有数据,请使用以下链接 https://stackoverflow.com/a/4229001/8603832
于 2018-01-08T04:35:58.070 回答