私が尋ねた以前の質問 (これを参照) によると、アプリを配布した後に変更を加えて新しいデータを追加すると、テーブルの削除と再作成はうまく機能しません。データ。
これに対処するための推奨される戦略はありますか、および/またはこの問題を管理するために私がしなければならないことの例はありますか?
ありがとう
編集 :
こんなものでしょう
@Override
public void onUpgrade (SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion){
// TODO Auto-generated method stub
//This is why I'm currently trying
while(oldVersion < newVersion){
switch(oldVersion){
case 2:
//add new datas from version 2 here
break;
case 3:
//add new datas from version 3 here
break;
default:
break;
}
oldVersion++;
}
/*
try {
Log.i(DatabaseHelper.class.getName(), "onUpgrade");
TableUtils.dropTable(connectionSource, Category.class, true);
TableUtils.dropTable(connectionSource, Level.class, true);
TableUtils.dropTable(connectionSource, Hint.class, true);
TableUtils.dropTable(connectionSource, HintCount.class, true);
TableUtils.dropTable(connectionSource, Question.class, true);
// after we drop the old databases, we create the new ones
onCreate(db, connectionSource);
} catch (SQLException e) {
Log.e(DatabaseHelper.class.getName(), "Can't drop databases", e);
throw new RuntimeException(e);
}
*/
}