我有资产的zip文件 . 首次运行应用程序时,zip文件(所有文件和文件夹)将解压缩并存储在内部存储区域中 . 基本解压缩路径是 getFilesDir() . 由于zip还包含文件夹,我无法使用 openFileOutput ,因为它给出了错误,包含路径分隔符 . 所以我使用 FileOutputStream 而不是现在工作正常 . 由于 FileOutputStream 不期望私人旗帜 . 这些解压缩的文件和文件夹是我的应用程序专用的,还是可以从其他应用程序访问?

这是代码,

`public boolean unpackZip(InputStream is, String path) throws IOException {
        String filename;
        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
        ZipEntry ze;
        byte[] buffer = new byte[1024];
        int count; 

        while ((ze = zis.getNextEntry()) != null) {
        filename = ze.getName();

        // Need to create directories if not exists, or
        // it will generate an Exception...
        if (ze.isDirectory()) {
            File fmd = new File(path + filename);
            fmd.mkdirs();
            continue;
        }

        FileOutputStream fout = new FileOutputStream(path + filename);

        while ((count = zis.read(buffer)) != -1) {
            fout.write(buffer, 0, count);
        }

        fout.close();
        zis.closeEntry();
    }

    zis.close();
    return true;
}`