开发者

android problem in extracting zip file using ZipFile

开发者 https://www.devze.com 2023-01-04 12:53 出处:网络
try{ File f = new File(\"/data/cizip.zip\"); if(f.exists()){ ZipFile zf = new ZipFile(f); //this alway开发者_如何学Cs throws an error

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

精彩评论

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