Results 1 to 3 of 3
- 09-23-2009, 08:22 AM #1
dealing with database in wireless mobile midlet problem!
given this example
1) Improve the program such that records a listed not using a sequential for loop./*
* RmsExample1.java
*
* (c) 2005 J.E.D.I.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class RmsExample1 extends MIDlet implements CommandListener {
Display display;
RecordStore recStore = null;
int count = 0;
public static final Command exitCommand =
new Command("Exit", Command.EXIT, 1);
public static final Command newCommand =
new Command("New Record", Command.OK, 1);
public static final Command deleteCommand =
new Command("Delete Record", Command.OK, 1);
ChoiceGroup items = new ChoiceGroup( "Items", Choice.MULTIPLE );
public void startApp() {
if( display == null ){
display = Display.getDisplay( this );
display.setCurrent(new RmsForm());
loadStore();
}
}
public void pauseApp() {}
public void destroyApp(boolean unconditional){
//
Quit();
}
public void loadStore(){
byte[] data = new byte[16];
int recLength;
items.deleteAll();
try {
// Open or Create Record Store with name "RmsExample1"
recStore = RecordStore.openRecordStore("RmsExample1", true);
// Load contents of Record Store
for (int recId=1; recId<=recStore.getNumRecords(); recId++){
// getRecord returns the length of the record
recLength = recStore.getRecord(recId, data, 0);
// Convert the byte array into String
String item = new String(data, 0, recLength);
// update the display
items.append(item, null);
}
} catch (Exception e){items.append(e.toString(), null); }
}
class RmsForm extends Form {
RmsForm(){
// Setup the Form
super("RmsExample");
addCommand(exitCommand);
addCommand(newCommand);
addCommand(deleteCommand);
setCommandListener(RmsExample1.this);
append(items);
}
}
public void commandAction(Command c, Displayable d){
if(c == exitCommand){
Quit();
}
if (c == newCommand){
try {
// We will create a new Record
// This is the String we will put into the Record
String newItem = "Record #" + recStore.getNextRecordID();
// Convert the String into a byte array
byte[] bytes = newItem.getBytes();
// Write the Record into the Store
recStore.addRecord(bytes, 0, bytes.length);
// Update our display
items.append(newItem, null);
} catch (Exception e){}
}
if (c == deleteCommand){
try {
// We will create a new Record
// This is the String we will put into the Record
recStore.deleteRecord(recStore.getNextRecordID()-1);
items.delete (items.size()-1);
} catch (Exception e){}
}
}
public void Quit(){
if (recStore != null){
try {
recStore.closeRecordStore();
} catch (RecordStoreNotOpenException notopen){
// record store is not open
} catch (RecordStoreException rse){
// record store-related exception occurred
}
}
// Exit
notifyDestroyed();
}
}
2) Improve the checkboxes such that if it is checked then upon clicking delete only the checked items are deleted.
3) You should be able to delete 1 or more list items at a single instance.
Improve your program this time that is create the contents of each record based on the inputs of the users in the text field based on the given requirements:
1) The program will have three interfaces: Main interface, Add record interface and Delete Record interface.
2) The main interface will have a welcome screen and two choices add record and delete record with an EXIT and LAUNCH button.
3) The add record interface will result to 2 text boxes namely name and cellphone with two menu buttons BACK (which will return the main interface) and ADD which will create the record based on the content inputted in the textfield.
4) The delete record interface will list all the records created in checkbox list and the same as Machine problem 6 the user will just select the records to be deleted by selecting the checkbox and Delete button. It should also have a BACK button the will return to the main interface.
Hint bench mark on your MP #6, hence make sure your MP #6 is already functioning as prescribed.
PLEASE HELP ME IN THIS WORK TO DO... IM JUST A WOMAN AND WEAK WHEN IT COMES TO PROGRAMMING PLEASE HELP!!!
THANK YOU GENTLEMEN =)Last edited by coldvoice05; 09-23-2009 at 08:25 AM.
- 09-23-2009, 01:01 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What have you done so far and where are you stuck?
- 09-23-2009, 06:46 PM #3
Similar Threads
-
wireless mobile midlet problem
By coldvoice05 in forum Sun Java Wireless ToolkitReplies: 1Last Post: 02-14-2010, 01:54 PM -
Dealing with iReport 3.0.0
By HotEvilGirl in forum New To JavaReplies: 6Last Post: 09-11-2009, 11:32 AM -
Geting Mobile Number, Mobile Operator, Location and Mobile Serial Number by J2ME.
By maruffaiz in forum CLDC and MIDPReplies: 1Last Post: 08-07-2009, 12:14 PM -
Inconsistencies dealing with null
By xcallmejudasx in forum New To JavaReplies: 3Last Post: 05-11-2009, 08:58 PM -
how to connect to a PC database from a mobile aaplication?
By nathilen in forum Advanced JavaReplies: 0Last Post: 11-06-2008, 09:07 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks