This webinar will give you an in-depth look at strategies for persistent storage in Series 40 Java™ apps. In the presentation, we’ll examine two options, MIDP 2 RecordStore and the FileConnection API. RecordStore is part of the Java ME Record Management System (RMS). The webinar will provide an overview of usage scenarios, including state preservation between user sessions, local storage of configuration data, and other ways to use local storage to make your apps more compelling. In live coding demonstrations, Java expert Michael Samarin of Futurice will illustrate data-caching strategies using RecordStore for network-based applications and games.
1. WORKING WITH PERSISTENT STORAGE
ON NOKIA SERIES 40
Michael Samarin
Director,
Developer Training and Evangelism
Futurice
2. PERSISTENT STORAGE
• Keeping data between application sessions
• Caching data from network sessions for improving
application performance
• Extending application’s data or graphics assets (not
code), beyond 1 or 2 MB JAR file size limit
3. AVAILABLE OPTIONS
• FileConnection API
• Optional JSR-75, but available on all Series 40 devices
• RecordStore (also known as RMS)
• Part of MIDP specification
• Both APIs operates on file system level, but with different abstraction
layers
• There are no performance benefits of using one vs. another, they are
equally fast (or slow) – you should choose, according to your application
needs
• There are no widely known or used relational databases for Java ME
4. OPTION FileConnection
• FileConnection API gives you almost full access to file system, including
disk (memory cards), directories and files
• Methods for accessing streams with Java IO: InputStrem/DataInputStream
and OutpuStrem/DataOutputStream
• However, it is matter of Java ME security model, resulting in different
amount of permission dialogs interrupting application flow
• Amount of dialogs depends on signing, however 3rd party signing will not
completely suppress such dialogs
• Parts of file system are not available for accessing by 3rd party Midlets
http://www.developer.nokia.com/Resources/Library/Java/#!developers-guides/datahandling/file-
access/fileconnection-api.html
5. OPTION RecordStore (RMS)
• Each Midlet Suite allows to create multiple RecordStores (up to 2000, each with
maximum size 512KB on Series 40)
• Each RecordStore represents set of Records with unique numerical IDs (non
repeating, even when you delete existing records)
• Each record is just byte array of arbitrary length, so you read and write byte arrays,
and it is up to developer to serialize and de-serialize objects if needed
• Don’t fall into common trap of wrapping read/write operations into byte and data
streams, it really doesn’t matter on Java ME and only adds performance overhead
• Accessing RecordStores doesn’t trigger Java ME security model, so there will never
be any permission dialogs
• You can permit sharing RecordStore between Midlet Suites
http://www.developer.nokia.com/Resources/Library/Java/#!developers-
guides/datahandling/persistent-data.html