Hello, I don't know the RecordStore class. But I have one code which will help you to get to know more about this class, if you want to know. Use the code below to get more knowledge about the working of RecordStrore class in java.
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
public class Testing extends MIDlet
{
private RecordStore rstore = null;
static final String str = "Testing";
public void startApp()
{
openRecStore();
writeRecord("One");
writeRecord("Two");
readRecords();
closeRecStore();
deleteRecStore();
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
notifyDestroyed();
}
public void openRecStore()
{
try
{
rstore = RecordStore.openRecordStore(str, true );
}
catch (Exception e)
{
}
}
public void closeRecStore()
{
try
{
rstore.closeRecordStore();
}
catch (Exception e)
{
}
}
public void deleteRecStore()
{
if (RecordStore.listRecordStores() != null)
{
try
{
RecordStore.deleteRecordStore(str);
}
catch (Exception e)
{
}
}
}
public void writeRecord(String str)
{
byte[] rec = str.getBytes();
try
{
rstore.addRecord(rec, 0, rec.length);
}
catch (Exception e)
{
}
}
public void readRecords()
{
try
{
byte[] recData = new byte[5];
int len;
for(int i = 1; i <= rstore.getNumRecords(); i++)
{
if(rstore.getRecordSize(i) > recData.length)
{
recData = new byte[rstore.getRecordSize(i)];
}
len = rstore.getRecord(i, recData, 0);
System.out.println("Record " + i + " : " + new String(recData, 0, len));
}
}
catch (Exception e)
{
}
}
}
Bookmarks