use of com.zhan_dui.model.WatchRecord in project AnimeTaste by daimajia.
the class LoadActivity method updateFromOldVersion.
/**
* 从历史版本的数据库中迁移数据
*/
private void updateFromOldVersion() {
if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("updated", false)) {
return;
}
if (mContext.getDatabasePath(AnimeTasteDB.NAME).exists()) {
AnimeTasteDB db = new AnimeTasteDB(mContext, AnimeTasteDB.NAME, null, AnimeTasteDB.VERSION);
Cursor cursor = db.getReadableDatabase().query(true, "Video", null, "isFav=?", new String[] { String.valueOf(true) }, null, null, null, null);
while (cursor.moveToNext()) {
Animation animation = Animation.build(cursor);
animation.save();
}
cursor.close();
db.close();
Cursor watchCursor = db.getReadableDatabase().query(true, "Watched", null, null, null, null, null, null, null);
while (watchCursor.moveToNext()) {
WatchRecord record = new WatchRecord(watchCursor.getInt(watchCursor.getColumnIndex("vid")), true);
record.save();
}
cursor.close();
db.close();
}
PreferenceManager.getDefaultSharedPreferences(mContext).edit().putBoolean("updated", true).commit();
}
Aggregations