.gz 파일의 압축을 풀고 db 파일을 덮어 쓰려고하면 알 수없는 형식 (마법 번호 5153)이 표시됩니다. 압축 해제 및 덮어 쓰기에 대한 내 코드는 다음과 같습니다.알 수없는 형식 (매직 번호 5153)
InputStream fIn = c.getAssets().open("MyContacts");
// Path to the just created empty db
String outFileName = DB_PATH + DB_NAME;
//Open the empty db as the output stream
FileOutputStream myOutput = new FileOutputStream(outFileName);
GZIPInputStream gz = new GZIPInputStream(fIn);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[10246];
int length;
while ((length = gz.read(buffer, 0,buffer.length)) != -1){
myOutput.write(buffer, 0, length);
}
//Close the streams
gz.close();
myOutput.flush();
myOutput.close();
fIn.close();
코드가 정상적으로 보입니다. http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/ – zapl