私の.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