March
16
Posted on 16-03-2008
Filed Under (Java) by Dayson Pais

EasyDatabase is a custom class which I developed to manage and save application settings in your j2me applications instead of dealing with sometimes confusing methods of the javax.microedition.rms. It is a wrapper class around the RMS methods provided by MIDP 2.0.

It is very easy and efficient to use and requires no knowledge about MIDP Record Management System. It more or less works like how you store values in the windows registry(if you come from a windows background). Every value has a unique property name associated with it. For e.g AppVersion, LoginPassword, StudentsName, etc..

The code below demonstrates how to create a database called “UserInfo”. First we add the users “Name” & “Age”. Then, we retreive it and print it in the console.

EasyDatabase myDB = new EasyDatabase("UserInfo");
 
if(myDB.dBExists() == false)
{
	myDB.createDB(); //creates the db
	myDB.addProperty("Name", "Dayson"); //adds name
	myDB.addProperty("Age", "20"); //adds age
}
 
myDB.updateProperty("Age", "25", false); //changes age
 
System.err.println( myDB.getProperty("Name") ); //prints name
System.err.println( myDB.getProperty("Age") ); //prints age

Read the rest of this entry »

(1) Comment    Read More