Android "Bad magic number" error from readBundle
I've been using bundles to pass my information around my application and occasionally save them to a file by first passing them to a parcel.
For some reason occasionally when I try to put them back i开发者_开发知识库nto a bundle it springs a "readBundle: bad magic number" error on me generated by the following code:
FileInputStream fis = myContext.openFileInput(name);
byte[] buff = new byte[2048];
int length = fis.read(buff,0,2048);
fis.close();
Parcel p = Parcel.obtain();
p.unmarshall(buff, 0, length);
p.setDataPosition(0);
return p.readBundle();
精彩评论