这是我的代码, 我尝试在我的Sqlite数据库上执行随机查询。
我最终总是使用相同的值!!
请有人告诉我方向吗?
Thans!
int i2=gerRank(livello);
Random r = new Random();
int i1 = r.nextInt(i2);
Toast.makeText(this,Integer.toString(i1),Toast.LENGTH_SHORT).show();
Cursor parolaCursor = db.getReadableDatabase().rawQuery(
"SELECT _id, english, korean, difficulty FROM ordinato WHERE difficulty < "
+ Integer.toString(i1)+ " ORDER BY _id", null);
parolaCursor.moveToFirst();
答案 0 :(得分:0)
好的,解决了这个问题,请看新代码:
int i2=gerRank(livello);
Random r = new Random();
int i1 = r.nextInt(i2);
Cursor parolaCursor = db.getReadableDatabase().rawQuery(
"SELECT _id, english, korean, difficulty FROM ordinato WHERE difficulty < "
+ Integer.toString(i1)+ " ORDER BY difficulty DESC", null);
parolaCursor.moveToFirst();
诀窍是ORDER BY难度DESC