有关onUpgrade方法的android问题 [英] Question about onUpgrade method android
问题描述
我发表在Android Market的应用程序,现在我想提出一个新的版本与数据库中的变化。现在的问题是,我的版本已发布应用程序的具有此onUpgrade方法:
@覆盖
公共无效onUpgrade(SQLiteDatabase _db,诠释_oldVersion,诠释_newVersion){
Log.w(TaskDBAdapter,从版本升级+
_oldVersion +到+
_newVersion +,这将销毁所有旧数据);
//删除旧表。
_db.execSQL(DROP TABLE IF EXISTS+ DATABASE_TABLE_1);
_db.execSQL(DROP TABLE IF EXISTS+ DATABASE_TABLE_2);
//创建一个新的。
的onCreate(_db);
}
由于我想添加一个新表,我知道,我必须作出一些改变这里保持数据的我已经和previous版本创建的表。那么,什么onUpgrade方法会被调用,从旧的或新的.apk文件。我可以不断的从表中的数据?请告诉我。 感谢ü提前。
那么,什么onUpgrade方法会被调用,从旧的或新的.apk文件。
这是新的.apk文件。老走了,在这一点上。
我可以不断地从表中的数据?
您必须code你的,你保留你需要包括根据需要旧数据的数据这样的方式升级。
I have an application published in the android market, and now I want to make a new version with changes in the database. The problem is, my version of the app that is already published has this onUpgrade method:
@Override
public void onUpgrade(SQLiteDatabase _db, int _oldVersion, int _newVersion) {
Log.w("TaskDBAdapter", "Upgrading from version " +
_oldVersion + " to " +
_newVersion + ", which will destroy all old data");
// Drop the old table.
_db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE_1);
_db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE_2);
// Create a new one.
onCreate(_db);
}
Because I want to add a new table, I know that I have to make some changes here to keep the data from the tables I already created with the previous version. So what onUpgrade method will be called, from the old or from the new .apk. Can I keep the data from the tables? Please let me know. Thank u in advance.
So what onUpgrade method will be called, from the old or from the new .apk.
From new .apk. Old one is gone at this point.
Can I keep the data from the tables?
You have to code your upgrade in such a way that you retain data that you need including old data as required.
这篇关于有关onUpgrade方法的android问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!