1

I've read this post which was very near my question and I still didn't found what I was looking for.

I'm developing an application that relies on two plain-text files: let's say weekdays.txt and year.txt. One file has most likely (yet to define) seven lines, so it's very small (few bytes), but the other will contain 365 lines (one per each day of the year), which is not very big in bytes (20 Kb tops, my guess), but requires more processing power.

The app is not yet done, so I'll try to be explicit:

So my application will get the current date and the time and will look on weekdays.txt for the line that corresponds to the current day of the week, parse that line's information and store it in memory. After that the program should read year.txt and look for the line that corresponds to the current date and parse (and store in memory) that line's info.

Then it should do print out all the stored info.

When I say 'parse the info' I mean parsing Strings, something as simple as:

the string "7*1234-568" should be read as:

String ID=7;
int postCode=1234;
int areaCode=568;

The goal here is to create a light (and offline, this is crucial) application for quick use.
As you can see, this is a Developing 101 level application, and my question is: do you think this is too heavy work for any mobile phone? The reason I'm asking this is because I want my app to be functional in the biggest number of today's cellphones possible.

By the way, do you think for this kind of work I should instead be working with a database? I heard people around the forum talking of RMS and some said that it's kind of limited, so I just stayed the same. Anyway the idea of the txt files was to be easiest for the user to update just in case it's necessary...

Thanks in advance!

Community
  • 1
  • 1
K09P
  • 480
  • 4
  • 13

2 Answers2

2

If your config files are read-only and are not going to change with time, then you could include them inside the jar. You should be able to read them using Class.getResourceAsStream that returns an InputStream. An ASCII file with 366 lines (remember leap years) and 80 cols is around 29KB, so even 10 years old phones will read it without major problems (remember to perform IO in a separate thread though).

If the configuration could change, then you'll probably want to create a WS and have the phones fetch the config over the internet. To provide offline capabilities you could sync with the remote DB periodically and store the info in the device. RMS is record-based, and has a max size (device-dependent), but I think it is ok for your case. The drawback of this approach is that at least a first synchronization should be made, thus phones without a data plan will be left out.

Mister Smith
  • 27,417
  • 21
  • 110
  • 193
0

Since one of your requirement is to do it offline, I'd recommend using the RMS. I am not that confident in using files in j2me for such important data (not sure if it's better now) since it can be prone to errors and file corruptions.

If the amount of data you're going to save is as you say, 7 lines for weeks and 365 for years, then no problems with RMS.

Good luck!

Ian
  • 691
  • 3
  • 9