压缩放在res里面,然后按照apk,运行app的时候解压res里面的文件,放到sdcard上面,,,
解决方案 »
- 求助!!!一个关于textview的问题,高手看一下,给点思路
- android分享功能弹框列表中的程序是如何实现才能被分享的?
- 垂直 seekbar接口调用报错.
- GridView item的显示问题!
- 为什么图片在popupwindow中不能放大缩小??
- android手机游戏开发关于cocos2d的应用求大神!!急!!
- NDK编写的库怎么和上层JAVA用TCP/IP通信
- 关于Android系统分析
- Android下如何弹出图片浏览器选择框?
- 关于seekbar的拖动问题
- android客户端与服务器交互,传的数据是JSON格式,请问用webservice好呢还是http好呢?
- android文件下载urlConn.getInputStream()抛NUllPointerException
的
更好的应该是运行时自动从网上下载解压,只是不知道该怎么做。再等两天要是还没有更好的方法就结贴了,谢谢各位。我用到的解压方法如下:
/**
* 解压Assets中的文件
* @param context上下文对象
* @param assetName压缩包文件名
* @param outputDirectory输出目录
* @throws IOException
*/
public void unZip(Context context, String assetName,
String outputDirectory) throws IOException {
//创建解压目标目录
File file = new File(outputDirectory);
//如果目标目录不存在,则创建
if (!file.exists()) {
file.mkdirs();
}
else
{
return;
}
// Toast.makeText(Splash.this, "正在解压资源,请稍候", Toast.LENGTH_LONG).show();
InputStream inputStream = null;
//打开压缩文件
inputStream = context.getAssets().open(assetName);
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
//读取一个进入点
ZipEntry zipEntry = zipInputStream.getNextEntry();
//使用1Mbuffer
byte[] buffer = new byte[1024 * 1024];
//解压时字节计数
int count = 0;
//如果进入点为空说明已经遍历完所有压缩包中文件和目录
while (zipEntry != null) {
//如果是一个目录
if (zipEntry.isDirectory()) {
//String name = zipEntry.getName();
//name = name.substring(0, name.length() - 1);
file = new File(outputDirectory + File.separator + zipEntry.getName());
file.mkdir();
} else {
//如果是文件
String sFile = outputDirectory + File.separator
+ zipEntry.getName();
file = new File(sFile);
//创建该文件
file.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream(file);
while ((count = zipInputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, count);
}
fileOutputStream.close();
}
//定位到下一个文件入口
zipEntry = zipInputStream.getNextEntry();
}
zipInputStream.close();
}
新版本的android里面已经实现了把资源和执行文件的分离了
odex是用于这个的吗至少可以这么用吧
不过我不做app只做ROM 只是知道系统里面的应用这么打包
但是第三方的能不能这么玩 还真不清楚