我想用Environment变量替换一个上下文方法.
但不确定它们是否意味着相同.
有什么区别
getFilesDir()和Environment.getDataDirectory()?
我如何data\data从data\data\com.Myapp使用中获得Environment Variable?
我是android和java编程的新手,有人可以告诉我如何保存文件,我有以下代码:
InputStream is = new FileInputStream( location + "/zipSample.zip");
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
try {
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int count;
while ((count = zis.read(buffer)) != -1) {
baos.write(buffer, 0, count);
}
String filename = ze.getName();
byte[] bytes = baos.toByteArray();
// Do something with 'filename' and 'bytes' ...
// How do I save to sdcard?
}
} finally {
zis.close();
}
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助.