Someone on StackOverflow responded to my question there and mentioned it's a problem with compressed files. If the file is stored uncompressed it works. In order to do this (per their suggestion) I renamed my file to .mp3, which is a known compressed format to android, and the reads work.
It sounds like we need a way to specify these formats ourself, or to force a file to not be compressed during the packaging process. Either that or lift the 1MB restriction. On Aug 13, 2:25 pm, Jason Proctor <[email protected]> wrote: > yeah, looking at AssetManager.java, read() calls native > readAssetChar(), whereas read(byte[]) calls native readAsset(). > readAsset() throws the IOException if the underlying Asset.read() > returns negative. readAssetChar() just returns negative if the read() > fails, no throw. > > Asset.h has UNCOMPRESS_DATA_MAX set to a megabyte in the Android > case, which might be a clue. AFAICS UNCOMPRESS_DATA_MAX isn't > referenced anywhere else in the core code though (?). > > i can't spend any more time digging right now. can someone from the > droid team comment? i don't really want my application falling over > at a future date because some asset went over a megabyte. which is > quite likely. > > > > >I'm not exactly sure... I'm actually only reading the file 24 bytes at > >a time, so I'm not quite sure why the IOException is thrown. I'm > >never allocating a buffer for the full file. > > >If I do two sequential one byte reads it's fine... but a single 2 byte > >read (using read(byte[])) it throws the exception. The exception is > >thrown by AssetManager.readAsset. > > >On Aug 13, 2:09 pm, Jason Proctor <[email protected]> > >wrote: > >> why is there a 1mb file limit in this case? > > >> and is the restriction 1mb in the amount of stuff read, or in the > >> size of the file? > > >> could you maybe open the file, skip a megabyte, then continue to read > >> the second megabyte? > > >> >1048576 is the file limit > >> >If you have bigger file split it > > >> -- > >> jason.software.particle > > -- > jason.software.particle --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

