Android:如何删除旧测验并添加新测验?

时间:2015-03-24 18:37:41

标签: android android-studio android-sqlite

我正在进行Android测验,而且我使用SQLite拥有本地数据库。即使我已经更改了要显示的问题,也会显示相同的旧问题。

private void addQuestions()
{
    Question q1=new Question("What food makes up nearly all (around 99%)" +
            " of a Giant Panda’s diet?","Bamboo", "Bananas", "Grass", "A");
    this.addQuestion(q1);
}

// Adding new question
public void addQuestion(Question quest) {
    //SQLiteDatabase db = this.getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_QUES, quest.getQUESTION());
    values.put(KEY_ANSWER, quest.getANSWER());
    values.put(KEY_OPTA, quest.getOPTA());
    values.put(KEY_OPTB, quest.getOPTB());
    values.put(KEY_OPTC, quest.getOPTC());
    // Inserting Row
    dbase.insert(TABLE_QUEST, null, values);
}

1 个答案:

答案 0 :(得分:0)

将Sqlite版本更新为加1。

  

private static final int DATABASE_VERSION = 2;

  

private static final int DATABASE_VERSION = 3;

这将使您的应用程序创建新数据库并只插入新数据