Cannot Display the record store data

Forum for J2ME mobile games related topics including programming doubts, books and other resources for J2ME game development

Cannot Display the record store data

Postby thinkandapply » Fri Jan 09, 2009 2:48 pm

Hi every one i would like to display the record store data in the Gamecanvas but i am not able to do so please help.


File on 1

import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class a
extends MIDlet

{
private Display display;
String inputString;
rms test;
public RecordStore recordstore;
public a()
{
test();
}
public void startApp()
{
display = Display.getDisplay(this);
test=new rms(this);
test.start();
display.setCurrent(test);
}
public void pauseApp()
{
}
public void destroyApp( boolean unconditional )
{
}
public void test()
{

try
{
recordstore = RecordStore.openRecordStore(
"Scores", true );
}
catch (Exception error)
{
}
try
{
byte[] outputRecord;
String outputString = "AAkash";
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)
{

}
try
{
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();

System.out.println(inputString + inputBoolean);
}
catch (Exception error)
{

}
try
{

}
catch (Exception error)
{

}


}

}



File no 2 Th Gane Canvas


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Deepz
*/
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class rms extends GameCanvas implements Runnable {
private boolean isPlay;
private long delay;
private int currentX, currentY;
public a parent;
private int width;
private int height;

public rms(a parent ) {
super(true);
width = getWidth();
height = getHeight();
currentX = width / 2;
currentY = height / 2;
delay = 20;
}

public void start() {
isPlay = true;
Thread t = new Thread(this);
t.start();
}
public void stop() { isPlay = false; }

public void run() {
Graphics g = getGraphics();
while (isPlay == true) {
input();
drawScreen(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
}
}

private void input() {

}

private void drawScreen(Graphics g) {
g.setColor(0xffffff);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0x0000ff);
try{



g.drawString(parent.inputString,currentX,currentY,Graphics.TOP|Graphics.LEFT);
}
catch(Exception e)
{

}

}
}
thinkandapply
 
Posts: 15
Joined: Wed Nov 05, 2008 5:42 pm

Return to J2ME Games

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

cron