update升级包版本信息的读取
16lz
2021-01-26
android设备在用U盘升级的时候,要先判断U盘中的升级包是否匹配此机型,是否高于当前版本。如果这些都成立的话,那么才刷机。这里我列出一个读取U盘版本信息的例子,只要运用了ZipInputStream ZipEntry 。
public String getUdiskVersion() {
查看文本 打印 ?- Log.e(TAG,"-->getUdiskVersion()");
- StringzipFile="mnt/udisk/usb/USB_DISK0/udisk0/update.zip";
- Filef=newFile(zipFile);
- if(!f.exists()){
- return"";
- }
- FileInputStreamfis=null;
- try{
- fis=newFileInputStream(f);
- }catch(FileNotFoundExceptione1){
- //TODOAuto-generatedcatchblock
- e1.printStackTrace();
- }
- BufferedReaderreader=null;
- Stringstr="";
- Stringversion="";
- ZipEntryze=null;
- ZipInputStreamzis=null;
- try{
- zis=newZipInputStream(fis);
- while((ze=zis.getNextEntry())!=null){
- if(ze.getName().equals("system/build.prop")){
- Log.e(TAG,"找到了"+"路径是:"+ze.getName());
- break;
- }
- }
- reader=newBufferedReader(newInputStreamReader(zis,"GBK"));
- while((str=reader.readLine())!=null){
- if(str.startsWith("ro.product.model")){
- version=str.substring(str.indexOf('=')+1);
- Toast.makeText(this,version,0);
- Log.e(TAG,"-->str="+str);
- }
- }
- }catch(IOExceptione){
- e.printStackTrace();
- }finally{
- try{
- reader.close();
- ze.clone();
- zis.close();
- fis.close();
- }catch(IOExceptione){
- e.printStackTrace();
- }
- }
- returnversion;
转载自:http://www.verydemo.com/demo_c89_i41744.html
更多相关文章
- Android框架ButterKnife的使用详解,butterknife8.x.x版本的使用方
- [置顶] Android(安卓)Studio部分汉化中文包
- monkeyrunner官方文档翻译
- mmsPlayer, for android ,wince,windows,wm等
- 上官网学android之四(Supporting Different Devices)
- Android(安卓)Studio升级提示 Connection failed. Please check
- default.properties的target和AndroidManifest中的android:minSd
- Android(安卓)引入第三方so后启动报错 /lib/arm64-v8a, /vendor/
- Eclipse插件svn和TortoiseSvn版本对应关系