Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Store persistent data on the BlackBerry smartphone

by Retired ‎02-12-2010 02:39 PM - edited ‎09-16-2010 03:11 PM (4,753 Views)

Summary

 

This article applies to the following:

  • BlackBerry® Java® Development Environment (BlackBerry JDE)
  • BlackBerry smartphones

Description

 

Java® based BlackBerry smartphones can store data in one of the following ways:

  • Using the Mobile Information Device Profile (MIDP) record stores
  • Using the BlackBerry Persistence model
  • Using the FileConnection application programming interface (API)

Storing data on a BlackBerry smartphone will allow the data to persist between instances of the applications and after resetting the BlackBerry smartphone.

 

Which method to use?


The method of storing data depends on the audience of the application.

 

If the application is meant to run strictly on the BlackBerry smartphone, use the BlackBerry Persistence model. On the other hand, if the application is portable across other Java 2 Platform, Micro Edition (J2ME) compatible devices, then use the MIDP record store method or the FileConnection API.

 

The biggest advantage of the PersistentStore class is that it allows storing and reading data as Objects, whereas MIDP record stores and FileConnection methods store data as byte arrays, which need to be parsed by applications to Objects.

 

For a complete overview on different ways to store persistent data on the BlackBerry smartphone, see the developer video Introduction to Persistence Models on BlackBerry Smartphones.

 

For further information and sample code, see the “Storing data” section of the BlackBerry Java Development Environment - Development Guide.

 

What type of data can be stored?


The following data types automatically implement the Persistable interface and thus can be stored:

  • java.lang.Boolean
  • java.lang.Byte
  • java.lang.Character
  • java.lang.Integer
  • java.lang.Long
  • java.lang.Object
  • java.lang.Short
  • java.lang.String
  • java.util.Vector
  • java.util.Hashtable

You can also create your own classes that implement the Persistable interface to store custom data objects.

Contributors
Users Online
Currently online: 62 members 2,093 guests
Please welcome our newest community members: