Problemas na comparação de strings em um RMS

Olá pessoal, ainda não entendo muito bem Java para dispositivos móveis, então queria uma mãozinha em algo que deve ser simples. :smiley:
Tenho uma aplicação armazenando senhas em um arquivo RMS. Se a senha não existir ele armazena no arquivo normalmente, agora, se a senha já existir, deve-se validar (sem a necessidade de armazená-la novamente) e passar para a próxima tela. Essa validação não estou conseguindo fazer por “vias normais” ou “for, if” etc … existe algum método que faria isso mais fácil? Só preciso comparar a string digitada varrendo todas as entradas armazenadas no RMS.

Aqui vai um pequeno pedaço de código onde eu faço o “try” da gravação da senha no RMS:

		                try{
		rs = RecordStore.openRecordStore(STORE_NAME, true);
		senha=txtPass.getString();
		

     	// Create a byte stream we can write to
     	ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();

     	// To make life easier use a DataOutputStream to write the bytes
     	// to the byteStream (ie. we get the writeXXX methods)
     	DataOutputStream dataOutputStream = new DataOutputStream(byteOutputStream);
     	dataOutputStream.writeUTF(senha);
     	// ... add other dataOutputStream.writeXXX statements if you like
     	dataOutputStream.flush();
	
     	// add the record
     
     	byte[] recordOut = byteOutputStream.toByteArray();
     	int newRecordId = rs.addRecord(recordOut, 0, recordOut.length);
     	System.out.println("Adicionando nova gravação: " + newRecordId +
                        " Valor: " + recordOut.toString());

     	dataOutputStream.close();
     	byteOutputStream.close();
     	
     	// retrieve the state of the store now that it's been populated
  		System.out.println("Armazenado " + rs.getNumRecords() +
                     " entrada(s) usando " + rs.getSize() + " byte(s) " +
                     "[" + rs.getSizeAvailable() + " bytes livres]");

		for (int i=1; i <= rs.getNumRecords(); i++){
		
		int recordSize = rs.getRecordSize(i);
     	if (recordSize > 0){
        // construct a byte and wrapping data stream to read back the
        // java types from the binary format
        ByteArrayInputStream byteInputStream = new ByteArrayInputStream(rs.getRecord(i));
        DataInputStream dataInputStream = new DataInputStream(byteInputStream);

        String value = dataInputStream.readUTF();
        // ... add other dataOutputStream.readXXX statements here matching the
        // order they were written above

        System.out.println("Obtida entrada: " + i + " Valor: " + value);

        dataInputStream.close();
        byteInputStream.close();
     	}
     	
		}
		}
		catch(Exception e){
			e.printStackTrace();
		}

=============================

Se alguém puder ajudar, ficaria muito grata =)
Obrigada.

Não pode usar um

você tem que fazer com RecordEnumeration.

tente um while.


        RecordStore rms;
        RecordEnumeration re = rms.enumerateRecords(null, null, false);

        int id;
        while (re.hasNextElement()) {
            id = re.nextRecordId();
            byte[] dados = rms.getRecord(id);
        }

Com isso vai conseguir correr todo seu RecordStore.

*DICA: USE AS TAGS CODE E /CODE