ai galera consegui fazer o cadastrar, listar e o alterar,mas não estou conseguindo fazer o consultar,aki em baixo está o código do consultar,deem uma olhada ai pra mim,pra ver se descobre aonde q estou errando…Agradeço desde já …
public void commandAction(Command C, Displayable D) {
if(C == sair){
notifyDestroyed();
}
if(C == cadastrar){
try {
rs=RecordStore.openRecordStore("Universidade", true);
byte bnome[]= (nome.getString()).getBytes();
byte bmatricula[] = (matricula.getString()).getBytes();
byte bcurso[]=curso.getString(curso.getSelectedIndex()).getBytes();
rs.addRecord(bnome, 0, bnome.length);
rs.addRecord(bmatricula, 0, bmatricula.length);
rs.addRecord(bcurso, 0, bcurso.length);
Alert mensagem = new Alert("Cadastrado","Aluno inserido com sucesso",null,null);
mensagem.setTimeout(2000);
tela.setCurrent(mensagem);
nome.setString("");
matricula.setString("");
rs.closeRecordStore();
}
catch(Exception e){
}
}
if(C == listar){
String aux = "";
try {
rs = RecordStore.openRecordStore("Universidade", true);
for(int i=1;i < rs.getNextRecordID();i+=3){
String lnome = new String(rs.getRecord(i));
String lmatricula = new String(rs.getRecord(i+1));
String lcurso = new String(rs.getRecord(i+2));
aux = aux +"Nome:"+lnome + "Matricula:"+lmatricula+ "Curso:"+lcurso ;
}
rs.closeRecordStore();
Alert msg = new Alert("Lista",aux, null , AlertType.INFO);
msg.setTimeout(3000);
tela.setCurrent(msg);
}
catch(Exception e){
}
}
if(C == alterar){
String aux = "";
try {
rs=RecordStore.openRecordStore("Universidade", true);
for(int i=1;i < rs.getNextRecordID();i+=3){
String busnome = new String (rs.getRecord(i));
if(busnome.equals(nome.getString())){
byte bnome[] = (nome.getString()).getBytes();
byte bmatricula[] = (matricula.getString()).getBytes();
byte bcurso[] = (curso.getString(curso.getSelectedIndex()).getBytes());
rs.setRecord(i, bnome, 0, bnome.length);
rs.setRecord(i+1, bmatricula, 0, bmatricula.length);
rs.setRecord(i+2,bcurso,0,bcurso.length);
aux = aux +"nome:"+bnome+"\nmatrícula"+bmatricula+"\nCurso:"+bcurso;
}
}
rs.closeRecordStore();
Alert alt = new Alert("Alterar","Registro alterado com sucesso",null,AlertType.INFO);
alt.setTimeout(3000);
tela.setCurrent(alt);
}catch (Exception e){
}
}
if(C == consultar){
String aux = "";
try {
rs = RecordStore.openRecordStore("Universidade", true);
for(int i = 1;i<rs.getNextRecordID();i+=3){
byte bnome[] = (nome.getString()).getBytes();
byte bmatricula[] = (matricula.getString()).getBytes();
byte bcurso[] = (curso.getString(curso.getSelectedIndex()).getBytes());
String buscarNome = new String(rs.getRecord(i));
if(buscarNome.equals(nome.getString())){
rs.getRecord(i, bnome,bnome.length);
rs.getRecord(i+1,bmatricula,bmatricula.length);
rs.getRecord(i+2,bcurso,bcurso.length);
aux = aux + "\nNome: "+bnome+"\nMatricula: "+bmatricula+"\nCurso: "+bcurso;
Alert msg = new Alert("Consulta",aux,null,null);
msg.setTimeout(3000);
tela.setCurrent(msg);
}
}
}
catch (Exception e){
}
}
}
}

