Android 往自己的APP加入文件
2011-07-19 12:06
357 查看
首先把自己需要安装的文件放在工程里的assert目录下。然后代码如下“;
/** @author xuxin *down load tht simotun file */ private void loadSimotunFile(){ if(!isFileExist(mexeFilePath)) try { InputStream in=getAssets().open("simotun") ; saveToFile(mexeFilePath,in); } catch (IOException e1) { e1.printStackTrace(); } }
/** @author xuxin * get inputStream,and write it to a new file */ public void saveToFile(String fileName, InputStream in) throws IOException { FileOutputStream fos = null; BufferedInputStream bis = null; int BUFFER_SIZE = 1024; byte[] buf = new byte[BUFFER_SIZE]; int size = 0; bis = new BufferedInputStream(in); fos = new FileOutputStream(fileName); while ( (size = bis.read(buf)) != -1) fos.write(buf, 0, size); fos.close(); bis.close(); }
相关文章推荐
- 如何在自己的Android APP中加入广告
- Android开发之生成自己的签名文件及App签名打包
- 【Android开发经验】APP的缓存文件到底应该存在哪?看完这篇文章你应该就自己清楚了
- Android开发之生成自己的签名文件及App签名打
- android如何在自己应用APP目录下创建文件
- Android开发之生成自己的签名文件及App签名打包
- android 去掉appcompat_v7 生成R文件 自己总结绝对可用
- cocos2dx 自己主动加入cpp文件到android.mk
- 【Android开发经验】APP的缓存文件到底应该存在哪?看完这篇文章你应该就自己清楚了
- Android添加文件打开方式,将你的app加入打开方式
- Android开发之生成自己的签名文件及App签名打包
- Android Share 将图片或者文件分享到自己的APP 中
- 如何将自己的APP加入android(比如附件的Digitclock)?--学习记录
- Android引导用户打开应用市场评分自己的app
- android studio 打包发布签名后的apk文件时出现Error:Execution failed for task ':app:transformClassesAndResourcesWi
- 找不到android.app.Activity的类文件解决办法
- Android App 实现分享功能及将应用加入分享列表 (分享功能可自定义需要分享的APP)
- Android下编译自己的库文件jar并在应用中调用
- Android app的文件缓存目录
- android studio R文件报错,com.android.support:appcompat-v7:21.+.