//==================================================================================*
// RMSData.java : Example of RMS coding,
// ************   This code is a mix of existing code source,
//		  It has not been tested in this version, free to you to complete it
//                and make necessary adaptation. Aim is to give an idea of coding
//==================================================================================*
//==================================================================================*
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
public public class RMSData {
	//==========================================================================*
	public RecordStore recStore=null;	//__ Buffer for reading ____________*
	static final String REC_STORE="AmazoniefishDB"; //__ Name of your DataBase _*

//==================================================================================*
	public RMSData() {
		//==================================== OPEN CREATE =================*
		try{
			recStore=RecordStore.openRecordStore(REC_STORE, true);
		}catch(Exception e){System.err.println(e.toString());}
		//==================================== WRITE =======================*
		byte data[]=null;
		try{
			ByteArrayOutputStream baos= new ByteArrayOutputStream();
			DataOutputStream dos= new DataOutputStream(baos);
			dos.writeInt(CdLang);
			dos.writeInt(MaVersion);

			data=baos.toByteArray();
			baos.close();
			dos.close();
		}catch(Exception e){System.err.println("KO_WR_PRE_Build:"+e.toString());}
		try{//================================= WRITE RECORD =========*
			recStore.addRecord(data,0,data.length);
			//recStore.setRecord(1,data,0,data.length);
		}catch(Exception e){
			System.err.println("KO_WRITE:"+e.toString());
		}
		//
		//==================================== READ ========================*
		try{
			byte Ludata[]= recStore.getRecord(1);
			ByteArrayInputStream bais= new ByteArrayInputStream(Ludata);
			DataInputStream dis= new DataInputStream(bais);
			CdLang	 =dis.readInt();
			MaVersion=dis.readInt();
			bais.close();
			dis.close();
		}catch(Exception e){System.err.println("KO_READBuild:"+e.toString());}
		//==================================== CLOSE =======================*
		try{
			recStore.closeRecordStore();
		}catch(Exception e){System.err.println(e.toString());}
	}
//==================================================================================*



//==================================================================================*
} //======= END OF MY PROGRAM ======================================================*
//==================================================================================*