Hi,

In BlackBerry device, we can store the data in following ways.

1) FileSystems (JAR 75)

2) Persistent Storage (persistent storage API)

3) MIDP Storage (MIDP RMS API,JSR37,JSR 118)

4) Sqlite Memory

File Systems:-

The JSR75 FileConnection API gives read and write capability to blackBerry filesystem. It supports both internal flash memory and any memory card.It also enables the read data from the other application and mainly it can retrieve the picture,video and other media data which are kept in the device already. But this very traditional method to store/retrieve the data in the memory.This FileConnection API are located in javax.microedition.io.file package.This is not a secure API.

FileConnection interface is designed to create / delete/ access files or directories from the device memory. The memory might be filesystems or removable media. To get the fileconnection using the Connector class from javax.microedition.io.Connector package. This connector class is uses to open the network connection in specified mode (Read / Write / Both).

If you want to open the file in READ_WRITE mode then use this syntax,

FileConnection fconn =null;

fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE);

(fName – Path for the file. Ex: file://SDCard/increment.txt )

Read Operation

public static String readTextFile(String fName) {
                    String result = null;
                    FileConnection fconn = null;
                    DataInputStream is = null;
                    try {
                       fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE);
                                 is = fconn.openDataInputStream();
                                 byte[] data = IOUtilities.streamToBytes(is);
                                 result = new String(data);
                         } catch (IOException e) {
                                System.out.println(e.getMessage());
                         } finally {
                                 try {
                                         if (null != is)
                                               is.close();
                                         if (null != fconn)
                                                fconn.close();
                                       } catch (IOException e) {
                                          System.out.println(e.getMessage());
                                       }
                        }
                 return result;
}

Write Operation:

public static boolean writeTextFile(String fName, String text) {
          DataOutputStream os = null;
          FileConnection fconn = null;
          boolean processCompleted=false;
          try {
              fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE);
                   if (!fconn.exists())
                           fconn.create();
                   os = fconn.openDataOutputStream();
                   os.flush();
                   os.write(text.getBytes());
                  processCompleted=true;
               } catch (IOException e) {
               } catch(IllegalModeException e){
              } finally {
                        try {
                               if (null != os)
                                   os.close();
                              if (null != fconn)
                                   fconn.close();
                           } catch (IOException e) {
                           } catch (Exception e){
                      }
                     }
           return processCompleted;
     }

But this is very traditional method for storing the data in the device memory. Currently Blackberry supports some new storage ways like persistent , sqlite.

I will catch you with persistent storage article.