开发者

android problem in extracting zip file using ZipFile

try{

File f = new File("/data/cizip.zip");
 if(f.exists()){
   ZipFile zf = new ZipFile(f); //this alway开发者_如何学Cs throws an error
/*some of my codes here*/
}
catch(IOException e){
   AlertDialog.Builder abd = new AlertDialog.Builder(this);
   abd.setMessage(e.getMessage());
   abd.show();
}

the line ZipFile zf = new ZipFile(f); always throws an error and I don't know why. And the error message is the file name ("/data/cizip.zip"), therefore I can't know the cause of the error. Can someone please tell me what causes this error? Thanks in advance.


This is just a guess, but maybe the file is in use (locked)? I don't see anything obviously wrong with your code...


Your app doesn't have read/write permissions directly in the /data/ directory. You should use either the correct subfolder "/data/data/your.program.package/" or just the "/sdcard/"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜