Package javax.microedition.rms facilitates the persistent storage of data. This feature is available in MIDP profile. So you can use it safely in your midlets.

The example below demonstrates how to read and write String array data. Each record store has id, length and array data.

 import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;

public class arrayStore extends MIDlet
{
  private RecordStore rs = null;
  static final String RECORD_STORE = "rmstest";

  public arrayStore()
  {
    open();
    writeData();
    readData(); 
    close();   
    delete();  
  }

  public void destroyApp( boolean unconditional )
  {}

  public void startApp()
  {
    destroyApp(false);
    notifyDestroyed();
  }

  public void pauseApp(){}
  
  /* Open RMS with filename */
  public void open()
  {
    try
    {
      rs = RecordStore.openRecordStore(RECORD_STORE, true );
    }
    catch (Exception e)
    {}
  }    

  /* Close RMS*/
  public void close()
  {
    try
    {
      rs.closeRecordStore();
    }
    catch (Exception e)
    {}
  }
  
  /* Delete RMS with filename*/
  public void delete()
  {
    if (RecordStore.listRecordStores() != null)
    {
      try
      {
        RecordStore.deleteRecordStore(RECORD_STORE);
      }
      catch (Exception e)
      {}
    }      
  }

  /* Write String data with id assigned to each data*/
  public void writeData()
  {
    int ids[] = {1,2,3};
    String str1[] = {"A", "B", "C"};
    String str2[] = {"D", "E", "F"};
    String str3[] = {"G", "H", "I"};
    Object data[] = new Object[3];
    data[0] =str1;
    data[1]= str2;
    data[2]= str3; 
    writeStream(ids,data);
  }

  /* Write data to RMS */
  public void writeStream(int[] ids,Object[] data)
  {
    try
    {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      DataOutputStream ds = new DataOutputStream(baos);
      byte[] record;

      for (int i = 0; i < ids.length; i++)
      {
        ds.writeInt(ids[i]); // write id
        String str[] = (String[])data[i];
        ds.writeInt(str.length); // write length of data
        
        for (int j=0;j<str.length;j++)
        {
          ds.writeUTF(str[j]); // write array data
        }
        
        ds.flush();
        record = baos.toByteArray();
        
        // Add record data to recordstore
        rs.addRecord(record, 0, record.length);      
        baos.reset();
      }
      
      baos.close();
      ds.close();
    }
    catch (Exception e)
    {}
  }

  /* Read data from recordstore*/
  public void readData()
  {
    try
    {
      byte[] recData = new byte[50];
      ByteArrayInputStream bais = new ByteArrayInputStream(recData);
      DataInputStream ds = new DataInputStream(bais);

      for (int i = 1; i <= rs.getNumRecords(); i++)
      {
        // Get data into the byte array
        rs.getRecord(i, recData, 0);

        System.out.println("Record #" + i);        
        System.out.println("ID: " + ds.readInt());
        int length = ds.readInt();
        System.out.println("Length: " + length);
        for(int j =0 ;j<length;j++)
        {
          System.out.println("Data: " +ds.readUTF());
        }
        System.out.println("--------------------");        
        bais.reset();
      }
      bais.close();
      ds.close();
    }      
    catch (Exception e)
    {}
  }
}