Question

I know that Serialization (Serializable) is not available in the Micro Edition of Java. It's kinda straight forward to save primitives like int and java.lang.String objects with the RMS. But if I want to save (make persistant) an arbitrary object? Is that possible?

Was it helpful?

Solution

You can use the Connection API to write the data to a File/Stream. Please keep in mind that it is easy to persist the data in to a Stream but inorder to restore the data from the Stream you will have to write your own code. Usually reflection is used for this purpose and it becomes a bottle neck on many devices.

So instead of re-inventing the wheel I would advise using Floggy (http://floggy.sourceforge.net/). Floggy is a free object persistence framework for J2ME/MIDP applications. The main goal of this framework is to abstract the data persistence details from the developer, reducing the development and maintenance effort. You can check the examples at http://floggy.sourceforge.net/getting-started.html#framework

OTHER TIPS

Unfortunately there's no way to save an arbitrary object without writing code for it, since reflection is severely limited in J2ME (you can look up classes, but can't look up their fields and methods).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top