Storing data
Overview
There are several ways you can store, share, and manage data for your apps:
Data storage approach | Description and API |
---|---|
Store data in relational databases with the Database API. |
|
Store data in files and folders with the FileConnection API. |
|
Save objects across smartphone restarts with the PersistentStore API. |
|
Save objects nonpersistently, which is useful for sharing data between applications and creating system-wide singletons, with the RuntimeStore API. |
|
Record store |
Store data in the MIDP Record Management System with the RMS API. |
Here's a comparison of the data storage approaches:
Features |
SQLite database |
File system |
Persistent store |
Runtime store |
Record store |
---|---|---|---|---|---|
Data format |
Relational database file |
Any |
Java object |
Java object |
Serialized |
Storage locations |
External media card, built-in media storage |
Application storage, external media card, built-in media storage |
Application storage |
Application storage |
Application storage |
Maximum storage limit |
Size of partitions the user has access to |
Size of partitions the user has access to |
Available application storage |
Available application storage |
Differs according to BlackBerry Device Software version |
BlackBerry Device Software support |
5.0 or later |
4.2 or later |
All |
3.6 or later |
All |
Persists across device restarts |
Yes |
Yes |
Yes |
No |
Yes |
Applications can share data |
Yes |
Yes |
Yes |
Yes |
Yes |
When choosing a data storage approach, keep the following in mind:
- The file system and SQLite databases are typically the most efficient storage location for large, read-only files such as videos or large graphics.
- Memory on wireless devices can be very limited, so you should consider not storing all data on the smartphone. BlackBerry smartphones are frequently connected so your application can access data when needed. In many cases, the best approach is to store data across smartphone restarts only for data that is frequently accessed.
- When you consider where to store essential data, keep in mind that microSD cards can be removed.
- There is more latency in writing to application storage than there is in reading from it. For example, reading from the persistent store is relatively fast while commits are relatively slow.
- The file system and record store are standards-based approaches, while the persistent store and runtime store are specific to BlackBerry smartphones. If you want your application to run on other Java MEcompatible devices, you should consider a standards-based approach.
Storage locations
Different BlackBerry smartphones support different places to store data. The following storage locations are available, depending on the smartphone model:
Application storage |
This storage location is internal to the smartphone. It contains the operating system, the BlackBerry Java Virtual Machine, and an internal file system. Application storage is also called flash memory and on-board memory. Application storage is the only place on a BlackBerry smartphone from which apps can be run. All BlackBerry smartphones have application storage. |
External media card storage |
This storage location is a microSD card that BlackBerry smartphone users can insert to extend the amount of storage on their smartphones. It is optional and removable. A FAT file system is mounted on the media card. MicroSD cards are supported on all smartphones running BlackBerry Device Software 4.2 or later, with the exception of the BlackBerry 8700 Series. |
Built-in media storage |
This storage location is an embedded multimedia card called eMMC. It is not removable. A FAT file system is mounted on the built-in media card. Built-in media storage is also called internal media memory and on-board device memory. Built-in media storage is included on some BlackBerry smartphone models. |