1

I'm writing a J2ME dictionary app and I'm stuck on which is the best way to store the content in the app. I don't want the app to be too big. I want to store the descriptions of the words in a dictionary. Please help me.

I know about RMS but I don't want to use RMS because all the words in a dictionary and their descriptions cannot fit into an RMS.

I intend to work only offline, without accessing data from the web.

Community
  • 1
  • 1
sammyukavi
  • 1,501
  • 2
  • 23
  • 51

3 Answers3

1

A dictionary is a map where the key is the word and the value is the description. You can have a Hashtable for it.
To store the values in you jar file use Java .properties file. Each line will kabe a key value pair.
Then you open that file with Class.getResourceAsStream and parse it.

Telmo Pimentel Mota
  • 4,033
  • 16
  • 22
0

J2me apps can use a thing called RMS, which is cool to use to read/write data from the app only. If you want to read external files, your app will ask for user permission, which might not be cool.

RMS is used in stuff like storing a game preferences, for example.

Keep in mind RMS is pretty simple and doesn't support stuff like SELECT. You iterate through the contents, only.

Will
  • 14,348
  • 1
  • 42
  • 44
  • I know about RMS but I don't want to use RMS because all the words in a dictionary and their descriptions cannot fit into an RMS. – sammyukavi Nov 13 '12 at 13:52
  • I see. I think there is no choice but to go with file handling. Unless you want to zip it into RMS. Do you intend to work only offline? – Will Nov 13 '12 at 14:00
  • Have you checked this? http://stackoverflow.com/questions/19011/best-practice-for-storing-large-amounts-of-data-with-j2me – Will Nov 14 '12 at 14:39
0

I tried just reading through the file. It took half a minute. It is certain that we cannot use a single file to hold the data. Instead, store the data in multiple files. I used the following structure.

en
├───a
│       a.txt
│       b.txt
│       c.txt
│       ...
├───b   ...
├───c   ...
│
...

where word is in en/w/o.txt.

This method works fast. It seems the resources are compressed while creating the package, so this is the most convenient way to go.

Burak
  • 2,251
  • 1
  • 16
  • 33