如何使用SQLite数据库中的数据更新TextView?

时间:2015-10-15 17:04:38

标签: android

这是我在单击按钮时需要在TextView中更新的代码。 select采用随机整数并构造查询。

public void trueButtonClicked(View view){
            if(correct==1){
                select = Math.abs(random.nextInt(8));
                stringSelect = Integer.toString(select);
                cursor = db.query("QUESTION_TABLE",new String[]{"QUESTION", "isCORRECT", "DIFFICULTY"}, "_id = ?", new String[]{stringSelect},null, null, null);
                if(cursor.moveToPosition(select)){
                    showQuestion.setText(cursor.getString(0));
                    correct = cursor.getInt(1);
                    diff = cursor.getInt(2);
                }
            }
            else {
                Intent intent = new Intent(GameScreenActivity.this, GameEndActivity.class);
                startActivity(intent);
            }
        }

0 个答案:

没有答案