There are three persistent storage methods available directly for Java CLDC applications on BlackBerry devices:
- The MIDP record store
- RIM's persistent object API
- The file system, which is newly available in version 4.2 of the OS, and permits storage of multimedia files.
The record store and persistent object API are typically used by applications for storing configuration and other data so that it is hidden from other applications. We thought it would be interesting to compare the MIDP record store and the persistent object API, since they probably share at least some of the same underlying implementation, but code using the record store should be easier to port to other devices.
We tested reading and writing a 10-byte buffer to/from persistent storage, using each of the MIDP record store interface (javax.microedition.rms) and the RIM persistent object interface (net.rim.device.api), on a BlackBerry Curve 8300 running BlackBerry OS v22.214.171.124 (platform 126.96.36.199):
|Persistent Object Store||18.5 ± 0.4 ms/write||13.6 ± 0.2 us /read|
|MIDP Record Store||16.7 ± 0.3 ms/write||57.7 ± 4.6 us/read|
These were estimated using 10 runs of 1000 writes and 10 runs of 10000 reads; the ± figures denote standard deviation. Note how read speed is an order of magnitude faster than write.
The persistent object store read takes about a quarter of the time of the MIDP record store read, presumably because no copy is required (the persistent object store just returns a reference to an already instantiated object) and there is no indexing overhead, just a hash table lookup to find the reference.
So, use the Persistent Object Store unless you really value the additional portability or the 2 ms time difference on writes.