If performance is your main goal, a binary data blob with your own defined
structure is a likely candidate.  The current asset manager has a limit of
1MB for reading a compressed data stream; if you are wanting to do random
access, you could store it uncompressed in the .apk and open a direct fd to
it, but then you are facing the issue of creating an overly-large .apk.

You haven't really specified enough about what you are trying to do to be
able to offer a concrete solution.  How much data are you talking about?
 How do you want to access it?  How often do you need it?

On Tue, Nov 24, 2009 at 12: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<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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