0

这是我的代码,我尝试对我的 Sqlit 数据库执行随机查询。

我最终总是得到相同的值!

请问有人可以告诉我方向吗?

谢谢!

    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();
4

1 回答 1

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();     

诀窍是按难度 DESC 排序

于 2013-05-17T15:07:42.780 回答