I'd suggest using a trie, if the data is static, or mostly static. (If you need to add additional words, you can stick them in a splay tree).
It's fast, it's simple. It can be constructed in a way that it can be encoded as a byte array, and relevant portions read from a file, rather than loading it all into memory. (I say it's simple, but there are a lot of variations possible, so you have to decide what you're trying to optimize. I was curious just how much space this might take for a typical dictionary, so I threw a quick implementation together, that reads my Eclipse spell-check dictionary as a memory-based trie, and converts it to a byte-array-based trie format. The starting dictionary started out at 547539 bytes The byte-array-based trie was 693584 bytes, which is a lot less overhead than you'd get with any non-byte-array-based tree structure, a hash table, or a database. I used up to 3-byte offsets, for a max size > 2^24 bytes. Only 332 links needed 3 bytes. It's even smaller than an array of strings. But you'd save a small amount of space to do direct binary search in the raw file data. This would require scanning for entry boundaries, since they're variable length. On Mar 3, 3:04 pm, Harry68 <[email protected]> wrote: > Hello Everyone, > > I want to write an dictionary application for Android. > I want it offline with at least 5000words. > my questions are: > > what should I use to store my words, I mean is it a good idea to > create an ArrayList, hashmap etc? > if not then why and what do you propose? > > the more important thing for me this this how to create a database to > store the words which will be at least 5000 > I want the apps to work fast and work offline no need of network. > > thanks in advance -- 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

