Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

J2ME: perferred way to save / load data?

Thread view: 
Kevin - 06 Jul 2006 21:31 GMT
Hi,

I am pretty new to J2ME, can anyone give some hits of the good ways to
save / load data on these mobile devices using J2ME? Thanks a lot.

The way I currently know is:
to use the javax.microedition.rms.RecordStore
But it only handles byte[] arrays.
How about int, double, and Date (object)?
I know I can convert int and double to byte[], but not Date. (also,
this sounds not good).

Or, we can just use a file with java.io.DataInputStream like those in
normal j2se?

Any performance issues there?

Thanks a lot.
Thomas Hawtin - 06 Jul 2006 21:49 GMT
> I am pretty new to J2ME, can anyone give some hits of the good ways to
> save / load data on these mobile devices using J2ME? Thanks a lot.
[quoted text clipped - 8 lines]
> Or, we can just use a file with java.io.DataInputStream like those in
> normal j2se?

The obvious way to do it is with Data(In|Out)putStream feeding to a
ByteArray(In|Out)putStream.

Date can be converted into a long with getTime.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Kevin - 06 Jul 2006 23:11 GMT
So we must convert all these int (4 bytes), double (8 bytes), long (8
bytes) to byte[] arrays? Sounds not like a decent idea.......

How about to use the java.io.DataInputStream? I heard it may not have
good performance.

By the way, for RecordStore, is the get record by ID a "random access"
to the underlying file? Will the system hold all the records in memory?

Thanks all. :-)

> > I am pretty new to J2ME, can anyone give some hits of the good ways to
> > save / load data on these mobile devices using J2ME? Thanks a lot.
[quoted text clipped - 18 lines]
> Unemployed English Java programmer
> http://jroller.com/page/tackline/
AlecB - 07 Jul 2006 00:25 GMT
>>> I am pretty new to J2ME, can anyone give some hits of the good ways to
>>> save / load data on these mobile devices using J2ME? Thanks a lot.
[quoted text clipped - 28 lines]
>
> Thanks all. :-)

IFYP.

The recordstore can be accessed randomly. Be careful though, if you
perform deletes, the id of the first record will not be 1, which means
using a recordstore enumeration.

Data(In|Out)putStreams are very slow on certain devices. I recommend
only using them when you absolutely have to. you can usually do the
conversion yourself.

Regards,
Alec

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.