@Override public void characters(char[] ch, int start, int length) throws SAXException { if (this.tagName == null) return; String value = new String(ch, start, length); if (this.tagName.equalsIgnoreCase("UpdateInfo")) { if (mVersionInfo.mUpdateInfo == null) mVersionInfo.mUpdateInfo = ""; mVersionInfo.mUpdateInfo += value; } }
/** * 检查是否有缓存更新文件 * * @param context 当前上下文 * @param outVi 若有缓存更新信息,outVi为安装信息 * @param outPath 若有缓存安装文件,outPath记录安装路径,否则为null * @return 若返回false,说明没有缓存有效的更新文件,返回true说明有缓存更新文件 */ private boolean checkCache(Context context, final VersionInfo outVi, final StringBuffer outPath) { SharedPreferences sp = context.getSharedPreferences("update_info", Context.MODE_PRIVATE); outVi.mVersionCode = sp.getInt("versionCode", 0); outVi.mVersionName = sp.getString("versionName", null); outVi.mUpdateInfo = sp.getString("updateInfo", null); if (getCurrentVersionInfo(context).getVersionCode() >= outVi.getVersionCode()) { Log.d(tag, "当前版本比缓存版本更新"); return false; } outPath.append(sp.getString("savePath", null)); if (outPath == null || !new File(outPath.toString()).exists()) { Log.d(tag, "缓存文件不存在"); return false; } return true; }