bigfile.dataを圧縮してbigfile.zipとしたものを次の場所に設置した場合、
/assets/datadir/bigfile.zip
次の場所に解凍されます。
/data/data/com.example.sample.text/files/bigfile.data
String path = null;
try {
        AssetManager    am      = getResources().getAssets();
        InputStream     is      = am.open("datadir/bigfile.zip", AssetManager.ACCESS_STREAMING);
        ZipInputStream  zis     = new ZipInputStream(is);
        ZipEntry                ze      = zis.getNextEntry();
        if (ze != null) {
                path = getFilesDir().toString() + "/" + ze.getName();
                FileOutputStream fos = new FileOutputStream(path, false);
                byte[] buf = new byte[1024];
                int size = 0;
                while ((size = zis.read(buf, 0, buf.length)) > -1) {
                        fos.write(buf, 0, size);
                }
                fos.close();
                zis.closeEntry();
        }
        zis.close();
} catch (Exception e) {
        e.printStackTrace();
}
0 件のコメント:
コメントを投稿