Hi Timothy,

I don't know if this would help a lot.
Still the unserialization of the data will take a huge amount of time.
I already tested copying the whole file content to RAM, but the time
needed to read the data was nearly the same.


Regards

Marc Reichelt   ||   http://www.marcreichelt.de/


On 30 Nov., 15:15, Timothy F <megbec...@gmail.com> wrote:
> 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 <rockthesm...@hotmail.com> 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 <mcreich...@googlemail.com> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to