public class ResLoader {
/**
* @param res
* @throws IOException
* @throws FileNotFoundException
* @throws IOException
*/
static void unpackResources() throws FileNotFoundException, IOException {
final int BUFFER = 8192;
android.content.res.Resources t = TestingE3d.mContext.getResources();
InputStream fis = t.openRawResource(R.raw.resources);
if (fis == null)
return;
ZipInputStream zin = new ZipInputStream(new BufferedInputStream(fis,
BUFFER));
ZipEntry entry;
while ((entry = zin.getNextEntry()) != null) {
int count;
FileOutputStream fos = TestingE3d.mContext.openFileOutput(entry
.getName(), 0);
BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);
byte data[] = new byte[BUFFER];
while ((count = zin.read(data, 0, BUFFER)) != -1) {
dest.write(data, 0, count);
// Log.v("NOTAG", "writing "+count + " to "+entry.getName());
}
dest.flush();
dest.close();
}
zin.close();
}
}
R.raw.resources는 zip 파일입니다.이 클래스는 해당 zip의 모든 파일을 로컬 폴더로 압축을 해제합니다. NDK에 이것을 사용합니다.
당신을 통해 NDK에서 뒤마에 액세스 할 수 있습니다 /데이터/데이터 // 파일/
패키지 ResLoader이 파일 이름 = 원료에/resources.zip
파일 크기를 확인 했습니까? APK 파일은 ZIP 압축 파일이므로 어쨌든 압축 된 파일은 GZIPping에 아무런 가치가 없습니다. – CommonsWare
커먼웨어에 대한 반향으로, apk가 이미 압축되어 있기 때문에 gzipping 애셋이 apk 크기에 전혀 영향을 미치지 않는 것으로 나타났습니다. 여전히, 이것이 작동하지 않는 흥미로운 질문입니다. (예전에 테스트 할 때와 같은 시나리오가 있었기 때문에). –
int size = fIn.available(); <- java documentation says : EOF에 도달 한 후 0을 반환하고, 그렇지 않으면 항상 1을 반환합니다. – fazo