Database for mobile applications


SerME is very simple serialization and persistence library. It is intended to be used at J2ME (MIDP 1.0 and MIDP 2.0) which is not providing reflection and serialization capabilities. SerMe is able to store data using two APIs: first - RMS (javax.miroedition.rms) is standard for J2ME an dincluded in MIDP 1.0, second - using files, which are supported by package which is optional package for MIDP 2.0 implemented mostly on smartphones and PDA devices. SerME can be used in two modes: serilization and persistence.

Serialization mode

SerME provide ObjectInputStream and ObjectOutputStream which provides similar functionality with correspondent J2SE classes. The main difference is that because of lack of reflection, programmer is responsible to implement readObject/writeObject functions himself (in J2SE it is optional). Also class should have public default constructor (constructor without parameters) or should have no constructor at all. ObjectOutputStream serialize sequence of objects into the array of bytes. And ObjectInputStream can be used to extract objects packed in byte array. It is possible to use these classes to exchange objects through the net (in this case SerME should be used on both sides).

Persistence mode

This mode is needed for application which need to manipulate with particular objects (add/update/remove) and for which serialization approach (rewrite the whole object tree each time some modification is performed) is too inefficient. For such applications SerME provides IStorage class, which contains methods for manipulation with objects. Storage has single root object. Other persistent objects can be directly or indirectly accessed through root object. Also it is possible to iterate through all persistent objects in the storage.

Currently there are two implementation of IStorage interface - RmsStorage, based on javax.miroedition.rms package and FileStorage based on package. First alternative is available at all J2ME compatible environments. Each object is stored as separate record in RecordStore. Also metadata (names of the classes of persistent objects) is stored. The main disadvantage of this solution is thjat RMS implementation is very inefficient and its size is very restricted.

Second alternative is supported only by most advanced mobiles devices (such as smartphones and PDA). It provides much better performance.


SerME is open source product. The latest 2.06 version can be dowloaded here:

Reducing code size

The whole SerME code uses only 31Kb. But even this size is too large for mobile phone applications (where typical limit for Jar file size is now 64Kb). In this case it is possible to through away unused classes (for example, if you work with IStorage interface, then ObjectOutputStream and ObjectInputStream classes are not needed, and visa verse - if you are using SerME only for serialization, then org.garret.serme.rms package can be skipped). There is also yet another simple hint of decreasing code size - use obfuscator. Obfucator replaces identifiers written by programmer with generated ones, which are usually significantly smaller. Such simple thing can reduce size of .jar file up to 10%. If it is not enough, you can also leave support only of those types which are used in your application.

Look for new version at my homepage | E-Mail me about bugs and problems