/**
* This method takes care of updating all the tables in the database to the
* current version, creating them if necessary.
* This method can only update databases at schema 63 or higher, which was
* created August 1, 2008. Older database will be cleared and recreated.
* @param db Database
* @param internal True if this is the internal media database
*/ // Revisions 84-86 were a failed attempt at supporting the "album artist" id3 tag.
// We can't downgrade from those revisions, so start over.
// (the initial change to do this was wrong, so now we actually need to start over
// if the database version is 84-89)
// Post-gingerbread, revisions 91-94 were broken in a way that is not easy to repair.
// However version 91 was reused in a divergent development path for gingerbread,
// so we need to support upgrades from 91.
// Therefore we will only force a reset for versions 92 - 94.
if (fromVersion < 63 || (fromVersion >= 84 && fromVersion <= 89) ||
(fromVersion >= 92 && fromVersion <= 94)) {不明白这些东西?
* This method takes care of updating all the tables in the database to the
* current version, creating them if necessary.
* This method can only update databases at schema 63 or higher, which was
* created August 1, 2008. Older database will be cleared and recreated.
* @param db Database
* @param internal True if this is the internal media database
*/ // Revisions 84-86 were a failed attempt at supporting the "album artist" id3 tag.
// We can't downgrade from those revisions, so start over.
// (the initial change to do this was wrong, so now we actually need to start over
// if the database version is 84-89)
// Post-gingerbread, revisions 91-94 were broken in a way that is not easy to repair.
// However version 91 was reused in a divergent development path for gingerbread,
// so we need to support upgrades from 91.
// Therefore we will only force a reset for versions 92 - 94.
if (fromVersion < 63 || (fromVersion >= 84 && fromVersion <= 89) ||
(fromVersion >= 92 && fromVersion <= 94)) {不明白这些东西?
举个例子
public DBHelper(Context context, String name, CursorFactory factory,
int version) {如果这个version你默认是1,
在数据库的时候你输入的参数是2,就会执行onUpgrade删除你原来的数据库,重新更新。