A combination of res/raw and java.nio.channels.FileChannel.map() are
likely to give you the best performance.  If you know your maximum
record size, then using get on the Buffer into a byte array, b, then
wrapping that in a new DataInputStream(new ByteArrayInputStrea(b))
will make it easy to read.

On Nov 27, 6:17 am, Rockthesmurf <[email protected]> wrote:
> I package up all my files in to a single file - rename it to mp3 and
> put it in res/raw. I then get get file descriptor/offset/size and pass
> it over JNI to C code which I can then access the files data at an
> acceptable speed. My APK is around 10MB.
>
> Steve
>
> On Nov 24, 8:09 am, Marc Reichelt <[email protected]> wrote:
>
>
>
> > Hi!
>
> > I am writing a program where I have to access some static data, and
> > now I am looking for the best method of how to include them into the
> > project.
>
> > This is what I found out by now:
>
> > 1. Reading in the data by parsing an XML is *slow* (even using the SAX
> > parser).
> > 2. Reading the data by parsing a CSV file is faster than loading an
> > XML, but again is too slow.
> > 3. Putting the data into a Java file directly (e.g. by defining an
> > array) fails because Dalvik says it is too large.
> > 4. Reading in the data using serialization is slow. The funny thing
> > here is: It takes a bit longer than loading the XML file.
> > 5. Reading in the data from a SQLite database is the fastest method
> > until now. But a bad workaround is needed: A SQLite DB can not yet be
> > read directly from the resources, but instead has to be copied to the
> > cache or to the SD card - even for read-only access.
>
> > Right now I am using method 5, but I would really like to use a more
> > simplified and faster solution.
>
> > What I found out: Unserialization in Java is *fast* (reading a HashMap
> > with 5000 integers and strings in 79ms on my PC), while the same
> > action on my G1 takes over 13500ms. I know that I can not compare a PC
> > to a mobile device. But still, there seems to be a big difference
> > here. I think that the JRE directly copies the serialized data to RAM,
> > while Dalvik seems to read every object step by step. Is this going to
> > change in the future?
>
> > And, most interestingly: what do you do to access lots of static
> > information?
>
> > Thanks in advance & happy hacking
>
> > Marc Reichelt   ||  http://www.marcreichelt.de/

-- 
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

Reply via email to