Hai all....
Please help me.
I were write some code to read data store from rms and store it to List in j2me (lstInbox.append(.....)). While I read 1 line index from List, my Form (frmInbox) so always show all of data on rms (if read all of data is ok). And also, I cann't delete it one by one (delete all record is ok).
Can anyone help me, please?
Here my some code:
-----------------Begin:-----------------
public void bacaPesanMasuk() {
status = 1;
byte[] bPesan = null;
frmBaca.deleteAll();
try {
re = rs.enumerateRecords(null, this, true);
while (re.hasNextElement()) {
int i = re.nextRecordId();
bPesan = rs.getRecord(i);
ByteArrayInputStream bais = new ByteArrayInputStream(bPesan);
DataInputStream dis = new DataInputStream(bais);
try {
String noTelp = dis.readUTF();
String pesan = dis.readUTF();
byte[] dec = KompressDekompress.decompress(pesan.getBytes());
String dekompres = new String(dec);
if (smsQ.bBahasaIndonesia == true) {
frmBaca.append(dpQ.strTerimaDari[0] + noTelp + "\n");
frmBaca.append(dpQ.strTerimaDari[2] + "\n" + pesan + "\n\n");
frmBaca.append(dpQ.strTerimaDari[4] + "\n" + dekompres);
} else {
frmBaca.append(dpQ.strTerimaDari[1] + noTelp + "\n");
frmBaca.append(dpQ.strTerimaDari[3] + "\n" + pesan + "\n\n");
frmBaca.append(dpQ.strTerimaDari[5] + "\n" + dekompres);
}
} catch (IOException ioe) {
ioe.getMessage();
}
}
} catch (InvalidRecordIDException iride) {
iride.printStackTrace();
} catch (RecordStoreNotOpenException rsnoe) {
rsnoe.printStackTrace();
} catch (RecordStoreException rse) {
rse.printStackTrace();
}
Display.getDisplay(smsQ).setCurrent(frmBaca);
}
public void hapusSemuaPesanMasuk() {
try {
re = rs.enumerateRecords(null, null, false);
while (re.hasNextElement()) {
int i = re.nextRecordId();
byte[] bScore = rs.getRecord(i);
ByteArrayInputStream bais = new ByteArrayInputStream(bScore);
DataInputStream dis = new DataInputStream(bais);
rs.deleteRecord(i);
Alert aHapusPesan;
if (smsQ.bBahasaIndonesia == true) {
aHapusPesan = new Alert(dpQ.strLabelCommand_i[3], dpQ.strPesanDihapus[0], null, AlertType.CONFIRMATION);
} else {
aHapusPesan = new Alert(dpQ.strLabelCommand_e[3], dpQ.strPesanDihapus[1], null, AlertType.CONFIRMATION);
}
aHapusPesan.setTimeout(2000);
Display.getDisplay(smsQ).setCurrent(aHapusPesan, this);
}
re.rebuild();
} catch (InvalidRecordIDException iride) {
iride.printStackTrace();
} catch (RecordStoreNotOpenException rsnoe) {
rsnoe.printStackTrace();
} catch (RecordStoreException rse) {
rse.printStackTrace();
}
}
----------------End of code-------------
Note:
ID En
Baca Read
Pesan Message
Masuk In
Hapus Delete
So sorry for my bad english.
Thanks u so much