0

So I have to save a lot of data (simple string) within the application for auto-complete purposes. Its basically a list of all UK post-codes.

Since there are like a MILLION different codes, I was wondering what would be the best way to do this stuff. Putting them in a simple array is plain stupid (and impractical really).

How to best approach this?

Community
  • 1
  • 1
Asim
  • 6,962
  • 8
  • 38
  • 61

3 Answers3

0

Just Put Your Data In To SqLite Database And Store Data Base In Project:Asset Folder And Retrieve Data From that folder

May Be its easy Way.

Because If you store Data In Preferences, then Your App will Occupy more Space When Installed.

Sahil Mahajan Mj
  • 11,033
  • 8
  • 53
  • 100
Digvesh Patel
  • 6,503
  • 1
  • 20
  • 34
  • 1
    You can't retrieve data directly from an SQLite db in the assets folder. It will need to be copied to the app's private data base location before it can be used. – Ted Hopp Dec 24 '12 at 06:26
  • @TedHopp Can you guide me in this regard? My data is quite simple. Just one Table I guess. Postcodes. – Asim Dec 24 '12 at 08:52
0

Huffman code is one option for compressing the data: http://en.wikipedia.org/wiki/Huffman_coding

Take a look here for a concrete implementation: http://rosettacode.org/wiki/Huffman_coding

You can then store the tree in a physical as suggested here: Efficient way of storing Huffman tree

Community
  • 1
  • 1
Lior Ohana
  • 3,467
  • 4
  • 34
  • 49
0

If you have not read the docs on Android storage options, this is the place to start. Generally, for such large data sets, a database will be most time and space efficient.

Phil
  • 35,852
  • 23
  • 123
  • 164