//定义assetmanager对象
AssetManager assetManager = getAssets();
// 需要解压的对象
InputStream dataSource = assetManager.open("ShiningTrip.zip");
// 調用解压的方法
ZipUtil.unzip(dataSource, android.os.Environment
.getExternalStorageDirectory() + "");
public static void unzip(InputStream zipFileName, String outputDirectory) {
try {
ZipInputStream in = new ZipInputStream(zipFileName);
// 获取ZipInputStream中的ZipEntry条目,一个zip文件中可能包含多个ZipEntry,
// 当getNextEntry方法的返回值为null,则代表ZipInputStream中没有下一个ZipEntry,
// 输入流读取完成;
ZipEntry entry = in.getNextEntry();
while (entry != null) {
// 创建以zip包文件名为目录名的根目录
File file = new File(outputDirectory);
file.mkdir();
if (entry.isDirectory()) {
String name = entry.getName();
name = name.substring(0, name.length() - 1);
file = new File(outputDirectory + File.separator + name);
file.mkdir();
} else {
file = new File(outputDirectory + File.separator + entry.getName());
file.createNewFile();
FileOutputStream out = new FileOutputStream(file);
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
out.close();
}
// 读取下一个ZipEntry
entry = in.getNextEntry();
}
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
分享到:
相关推荐
NULL 博文链接:https://hzy3774.iteye.com/blog/1704419
AAPT - Android Asset Packaging Tool
android play Asset Delivery 打包工具和批处理文件,用于快速生成apks。 注意需要,替换签名文件!。
Android Asset Studio Open the Android Asset Studio See the older version if you're having trouble with the new version A web-based set of tools for generating graphics and other assets that would ...
Android中安装asset下的apk
IDE是android studio,不过其实主要内容还是在MainActivity
zip格式的压缩包放在asset中复制到SD卡上并解压.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。
zip格式的压缩包放在asset中复制到SD卡上并解压,压缩包里可以放多张图片和数据库,同时还解决了解压中出现的中文乱码问题。如果你的压缩包解压出现乱码,请在ZipUtil中自行设置编码格式
本demo是结合博客的资源,如有不懂请去看博客 http://blog.csdn.net/u013895206 ,文章是:android 使用gradle导出jar包,并包含assets资源文件夹。谢谢!
UE 4 虚幻引擎游戏开发综合开发能力训练(技能系统的练习)视频教程 第5小节 Health Regen Ability 所使用到的贴图
android Play Asset Delivery的源代码,注意需要用最新版本的AndroidStudio运行。
android中在sd卡上复制建立文件夹,以及在包下建立文件夹,以及复制asset文件到sd卡。
aapt工具(Android Asset Packaging Tool)
将assets下的资源复制到SD卡,实现了一个工具类,传入两个路径即可。
AssetStudio.v0.16.0中文版.zip
包括aapt(Android Asset Packaging Tool):编译应用程序的资源文件(包括AndroidManifest.xml和你的Activities的xml文件),生成R.java文件,这样你就可以从你的java代码中引用资源。aidl:把.aidl 接口转换成java...
最近在做新闻内容页面,实现页面字体的控制。我采用的办法是,在Android asset载入html资源,webview调用该html,实现android中的button,调用html中的JS方法,实现控制字体的大小。
Vector Asset中文名为矢量资源,在android studio中可以直接使用,当我们需要一些起导向作用的图片的时候,我们就可以直接调用Vector Asset。而且Vector Asset有一个特别好的优点就是不会出现图片失真的情况。 Vecto...
Asset Hunter Pro 1.2.8.zip Asset Hunter Pro 1.2.8.zipAsset Hunter Pro 1.2.8.zipAsset Hunter Pro 1.2.8.zip
AssetStudio-0.15.0.zip. 非常好用的对unity3d项目资源解包.可以获得apk包种的资源.