Wednesday, October 30, 2013

RecordEnumerationExample

import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class RecordEnumerationExample
extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command start;
private RecordStore recordstore = null;
private RecordEnumeration recordEnumeration = null;
public RecordEnumerationExample ()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
form = new Form("RecordEnumeration");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
        {
}
public void commandAction(Command command,
Displayable displayable)
{
    if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (command == start)
{
try
{
recordstore = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
alert = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
String outputData[] = {"First Record",
"Second Record", "Third Record"};
for (int x = 0; x < 3; x++)
{
byte[] byteOutputData = outputData[x].getBytes();
recordstore.addRecord(byteOutputData,
0, byteOutputData.length);
}
}
catch ( Exception error)
{
alert = new Alert("Error Writing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
StringBuffer buffer = new StringBuffer();
recordEnumeration =
recordstore.enumerateRecords(null, null, false);
while (recordEnumeration.hasNextElement())
{
buffer.append(new String(recordEnumeration.nextRecord()));
buffer.append("\n");
}
alert = new Alert("Reading",
buffer.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
catch (Exception error)
{
alert = new Alert("Error Reading",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
recordstore.closeRecordStore();
}
catch (Exception error)
{
alert = new Alert("Error Closing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
if (RecordStore.listRecordStores() != null)
{
try
{
    RecordStore.deleteRecordStore("myRecordStore");
recordEnumeration.destroy();
}
catch (Exception error)
{
alert = new Alert("Error Removing",error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
}
}
}
}


WriteReadMixedDataTypesExample


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.RecordStore;


public class WriteReadMixedDataTypesExample
extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command start;
private RecordStore recordstore = null;
public WriteReadMixedDataTypesExample ()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
form = new Form("Mixed Record");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
{
}
public void commandAction(Command command, Displayable displayable)
{
   
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (command == start)
{
try
{
recordstore = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
alert = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
byte[] outputRecord;
String outputString = "First Record";
int outputInteger = 15;
boolean outputBoolean = true;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
DataOutputStream outputDataStream =
new DataOutputStream(outputStream);
outputDataStream.writeUTF(outputString);
outputDataStream.writeBoolean(outputBoolean);
outputDataStream.writeInt(outputInteger);
outputDataStream.flush();
outputRecord = outputStream.toByteArray();
recordstore.addRecord(outputRecord, 0, outputRecord.length);
outputStream.reset();
outputStream.close();
outputDataStream.close();
}
catch ( Exception error)
    {
alert = new Alert("Error Writing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
String inputString = null;
int inputInteger = 0;
boolean inputBoolean = false;
byte[] byteInputData = new byte[100];
ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
DataInputStream inputDataStream =
new DataInputStream(inputStream);
for (int x = 1; x <= recordstore.getNumRecords(); x++)
{
recordstore.getRecord(x, byteInputData, 0);
inputString = inputDataStream.readUTF();
inputBoolean = inputDataStream.readBoolean();
inputInteger = inputDataStream.readInt();
inputStream.reset();
}
inputStream.close();
inputDataStream.close();
alert = new Alert("Reading", inputString + " " +inputInteger + " " +
inputBoolean, null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
catch (Exception error)
{
alert = new Alert("Error Reading",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
recordstore.closeRecordStore();
}
catch (Exception error)
{
alert = new Alert("Error Closing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
if (RecordStore.listRecordStores() != null)
{
try
{
RecordStore.deleteRecordStore("myRecordStore");
}
catch (Exception error)
{
alert = new Alert("Error Removing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
}
}
}
}


RecordStoreExample

import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class RecordStoreExample
extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command start;
private RecordStore recordstore = null;
private RecordEnumeration recordenumeration = null;
public RecordStoreExample ()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
form = new Form("Record Store");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
{
    }
public void commandAction(Command command, Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (command == start)
{
try
{
recordstore = RecordStore.openRecordStore("myRecordStore",
true );
}
catch (Exception error)
{
alert = new Alert("Error Creating", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
    {
recordstore.closeRecordStore();
}
catch (Exception error)
{
alert = new Alert("Error Closing", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
if (RecordStore.listRecordStores() != null)
{
try
{
RecordStore.deleteRecordStore("myRecordStore");
}
catch (Exception error)
{
alert = new Alert("Error Removing", error.toString(),null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
}
}
}
}

WriteReadExample

import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class WriteReadExample extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command start;
private RecordStore recordstore = null;
public WriteReadExample()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
form = new Form("Record");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
{
}
public void commandAction(Command command, Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (command == start)
    {
try
{
recordstore = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
alert = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
String outputData = "First Record";
byte[] byteOutputData = outputData.getBytes();
recordstore.addRecord(byteOutputData, 0,
byteOutputData.length);
}
catch (Exception error)
{
alert = new Alert("Error Writing",error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
byte[] byteInputData = new byte[1];
int length = 0;
for (int x = 1; x <= recordstore.getNumRecords(); x++)
{
if (recordstore.getRecordSize(x) > byteInputData.length)
{
byteInputData = new byte[recordstore.getRecordSize(x)];
}
length = recordstore.getRecord(x, byteInputData, 0);
}
alert = new Alert("Reading", new String(byteInputData, 0,
length), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
catch (Exception error)
{
alert = new Alert("Error Reading", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
recordstore.closeRecordStore();
}
catch (Exception error)
{
alert = new Alert("Error Closing", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
if (RecordStore.listRecordStores() != null)
    {
try
{
RecordStore.deleteRecordStore("myRecordStore");
}
catch (Exception error)
{
alert = new Alert("Error Removing", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
}
}
}
}

//compile and execute
then we will get the following output:

Tuesday, October 29, 2013

Date field class

import java.util.Date;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class DateEx extends MIDlet implements CommandListener
{
    private Display d;
    private Form f;
    private Date dat;
    private Command exit;
    private DateField df;
    public DateEx()
    {
        d=Display.getDisplay(this);
        f=new Form("To day's date");
        dat=new Date(System.currentTimeMillis());
        df=new DateField("",DateField.DATE_TIME);
        df.setDate(dat);
        exit=new Command("Exit",Command.EXIT,1);
        f.append(df);
        f.addCommand(exit);
        f.setCommandListener(this);
   
    }

    public void startApp() {
        d.setCurrent(f);
       
    }
       
    public void destroyApp(boolean unconditional) {
    }
    public void commandAction(Command c,Displayable dd)
    {
        if(c==exit)
        {
            destroyApp(false);
            notifyDestroyed();
        }
    }
    public void pauseApp() {
    }
}

jdbc ppt


Sunday, October 20, 2013

DataOutputStream

DataInputStream

Record Comparator

Record Enumeration

example program for mixed record enumeration (MRecEnum)

//mixed record enumeration
import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class MRecEnum extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command start;
private RecordStore recordstore = null;
private RecordEnumeration recordEnumeration = null;
public MRecEnum ()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
form = new Form("Mixed RecordEnumeration");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
{
}
public void commandAction(Command command, Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (command == start)
{
try
{
recordstore = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
alert = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
byte[] outputRecord;
String outputString[] = {"First Record",
"Second Record", "Third Record"};
int outputInteger[] = {15, 10, 5};
boolean outputBoolean[] = {true, false, true};
ByteArrayOutputStream outputStream =
new ByteArrayOutputStream();
DataOutputStream outputDataStream =
new DataOutputStream(outputStream);
for (int x = 0; x < 3; x++)
{
outputDataStream.writeUTF(outputString[x]);
outputDataStream.writeBoolean(outputBoolean[x]);
outputDataStream.writeInt(outputInteger[x]);
outputDataStream.flush();
outputRecord = outputStream.toByteArray();
recordstore.addRecord(outputRecord, 0,
outputRecord.length);
}
outputStream.reset();
outputStream.close();
outputDataStream.close();
}
catch ( Exception error)
{
alert = new Alert("Error Writing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
StringBuffer buffer = new StringBuffer();
byte[] byteInputData = new byte[300];
ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData);
DataInputStream inputDataStream =
new DataInputStream(inputStream);
recordEnumeration = recordstore.enumerateRecords(
null, null, false);
while (recordEnumeration.hasNextElement())
{
recordstore.getRecord(recordEnumeration.nextRecordId(),
byteInputData, 0);
buffer.append(inputDataStream.readUTF());
buffer.append("\n");
buffer.append(inputDataStream.readBoolean());
buffer.append("\n");
buffer.append(inputDataStream.readInt());
buffer.append("\n");
alert = new Alert("Reading", buffer.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
inputStream.close();
}
catch (Exception error)
{
alert = new Alert("Error Reading",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
recordstore.closeRecordStore();
}
catch (Exception error)
{
alert = new Alert("Error Closing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
if (RecordStore.listRecordStores() != null)
{
try
{
RecordStore.deleteRecordStore("myRecordStore");
recordEnumeration.destroy();
}
catch (Exception error)
{
alert = new Alert("Error Removing",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
}
}
}
}

MRecEnum ppt


RecEnum

import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class RecEnum
extends MIDlet implements CommandListener
{
private Display d;
private Alert a;
private Form f;
private Command exit;
private Command start;
private RecordStore rec = null;
private RecordEnumeration r = null;
public RecEnum()
{
d = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
f = new Form("RecordEnumeration");
f.addCommand(exit);
f.addCommand(start);
f.setCommandListener(this);
}
public void startApp()
{
d.setCurrent(f);
}
public void pauseApp()
{
}
public void destroyApp( boolean un )
        {
}
public void commandAction(Command c,
Displayable dd)
{
    if (c == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (c == start)
{
try
{
rec = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
a = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
try
{
String outputData[] = {"First Record",
"Second Record", "Third Record"};
for (int x = 0; x < 3; x++)
{
byte[] byteOutputData = outputData[x].getBytes();
rec.addRecord(byteOutputData,
0, byteOutputData.length);
}
}
catch ( Exception error)
{
a = new Alert("Error Writing",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
try
{
StringBuffer buffer = new StringBuffer();
r =
rec.enumerateRecords(null, null, false);
while (r.hasNextElement())
{
buffer.append(new String(r.nextRecord()));
buffer.append("\n");
}
a = new Alert("Reading",
buffer.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
catch (Exception error)
{
a = new Alert("Error Reading",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
try
{
rec.closeRecordStore();
}
catch (Exception error)
{
a = new Alert("Error Closing",
error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
if (RecordStore.listRecordStores() != null)
{
try
{
    RecordStore.deleteRecordStore("myRecordStore");
r.destroy();
}
catch (Exception error)
{
a = new Alert("Error Removing",error.toString(), null, AlertType.WARNING);
a.setTimeout(Alert.FOREVER);
d.setCurrent(a);
}
}
}
}
}

RecEnum.ppt

writing and reading record

//writing and reading record import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.midlet.MIDlet; import javax.microedition.rms.RecordStore; public class WREx2 extends MIDlet implements CommandListener { private Display d; private Alert a; private Form f; private Command exit; private Command start; private RecordStore rec = null; public WREx2 () { d = Display.getDisplay(this); exit = new Command("Exit", Command.EXIT, 1); //exit = new Command("Exit", Command.SCREEN, 1); start = new Command("Start", Command.SCREEN, 1); f = new Form("Mixed Record"); f.addCommand(start); f.addCommand(exit); f.setCommandListener(this); } public void startApp() { d.setCurrent(f); } public void pauseApp() { } public void destroyApp( boolean b ) { } public void commandAction(Command c, Displayable dd) { if (c == exit) { destroyApp(true); notifyDestroyed(); } else if (c == start) { try { //When a record is created, the record store assigns it a unique identifier, an integer called the record ID. rec = RecordStore.openRecordStore("myRecordStore", true ); } catch (Exception e) { /*a = new Alert("Error Creating", e.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a);*/ } try { byte[] by; //String oS = "First Record"; String oS = "Rama Rao"; int oI = 15; //boolean oB = true; char oB ='m'; //ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream ods = new DataOutputStream(baos); //read the data into ods object ods.writeUTF(oS); //read the data from oS into ods object //ods.writeBoolean(oB); ods.writeChar(oB); ods.writeInt(oI); ods.flush(); by = baos.toByteArray();//copies from baos[] array into by array,it creates a newly byte[] array, and returns byte[] reference rec.addRecord(by, 0, by.length); baos.reset(); baos.close(); ods.close(); } catch ( Exception error) { /*a = new Alert("Error Writing", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a);*/ } try { String s = null; int i = 0; //boolean b = false; char b='m'; byte[] by = new byte[100]; ByteArrayInputStream ist = new ByteArrayInputStream(by); //DataInputStream inputDataStream = DataInputStream ids = new DataInputStream(ist); for (int x = 1; x <= rec.getNumRecords(); x++) { rec.getRecord(x, by, 0); s = ids.readUTF(); //b = ids.readBoolean(); b=ids.readChar(); i = ids.readInt (); ist.reset(); } ist.close(); ids.close(); a = new Alert("Reading", s + " " +i + " " + b, null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); //alert msg is not dissappear immediately d.setCurrent(a); } catch (Exception error) { /*a = new Alert("Error Reading", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a);*/ } try { rec.closeRecordStore(); } catch (Exception error) { /*a = new Alert("Error Closing", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a);*/ } if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore("myRecordStore"); } catch (Exception error) { /*a = new Alert("Error Removing", error.toString(), null, AlertType.WARNING); a.setTimeout(Alert.FOREVER); d.setCurrent(a);*/ } } } } }

Record Store


writing and reading the record


//write read the record
import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class WriteReadExample extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command start;
private RecordStore recordstore = null;
public WriteReadExample()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.SCREEN, 1);
start = new Command("Start", Command.SCREEN, 1);
form = new Form("Record");
form.addCommand(exit);
form.addCommand(start);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
{
}
public void commandAction(Command command, Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
else if (command == start)
    {
try
{
recordstore = RecordStore.openRecordStore(
"myRecordStore", true );
}
catch (Exception error)
{
alert = new Alert("Error Creating",
error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
String outputData = "First Record";
byte[] byteOutputData = outputData.getBytes();
recordstore.addRecord(byteOutputData, 0,
byteOutputData.length);
}
catch (Exception error)
{
alert = new Alert("Error Writing",error.toString(), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
byte[] byteInputData = new byte[1];
int length = 0;
for (int x = 1; x <= recordstore.getNumRecords(); x++)
{
if (recordstore.getRecordSize(x) > byteInputData.length)
{
byteInputData = new byte[recordstore.getRecordSize(x)];
}
length = recordstore.getRecord(x, byteInputData, 0);
}
alert = new Alert("Reading", new String(byteInputData, 0,
length), null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
catch (Exception error)
{
alert = new Alert("Error Reading", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
try
{
recordstore.closeRecordStore();
}
catch (Exception error)
{
alert = new Alert("Error Closing", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
if (RecordStore.listRecordStores() != null)
    {
try
{
RecordStore.deleteRecordStore("myRecordStore");
}
catch (Exception error)
{
alert = new Alert("Error Removing", error.toString(),
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert);
}
}
}
}
}