JIMM will wear out your flash!
// Save contact list to record store static protected void save() throws IOException, RecordStoreException { // Try to delete the record store try { RecordStore.deleteRecordStore("contactlist"); } catch (RecordStoreNotFoundException e) { // Do nothing } // Create new record store RecordStore cl = RecordStore.openRecordStore("contactlist", true); // Temporary variables ByteArrayOutputStream baos; DataOutputStream dos; byte[] buf; // Add version info to record store baos = new ByteArrayOutputStream(); dos = new DataOutputStream(baos); dos.writeUTF(Jimm.VERSION); buf = baos.toByteArray(); cl.addRecord(buf, 0, buf.length); // Add version ids to the record store //todo check record store oversize - it seems to be the cause for JIMM failure for // quite big contact lists baos.reset(); dos.writeInt(ssiListLastChangeTime); dos.writeShort((short) ssiNumberOfItems); buf = baos.toByteArray(); cl.addRecord(buf, 0, buf.length); // Initialize buffer baos.reset(); // Iterate through all contact items int cItemsCount = cItems.size(); int totalCount = cItemsCount + gItems.size(); for (int i = 0; i < totalCount; i++) { if (i < cItemsCount) getCItem(i).saveToStream(dos); else { ContactListGroupItem gItem = (ContactListGroupItem) gItems .elementAt(i - cItemsCount); gItem.saveToStream(dos); } // Start new record if it exceeds 4000 bytes if ((baos.size() >= 4000) || (i == totalCount - 1)) { // Save record buf = baos.toByteArray(); cl.addRecord(buf, 0, buf.length); // Initialize buffer baos.reset(); } } // Close record store cl.closeRecordStore(); }
Путём пересоздавания и перезаписывания данных в record store каждый раз, при каждом малейшем изменении в контакт-листе!