From c41ab497836339237c54910527032ee8e3f0997f Mon Sep 17 00:00:00 2001 From: Josef Cacek Date: Thu, 20 Jun 2013 21:24:28 +0200 Subject: [PATCH] Issue #16 - removing profiles didn't work --- src/main/java/org/jboss/totp/TOTPMIDlet.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jboss/totp/TOTPMIDlet.java b/src/main/java/org/jboss/totp/TOTPMIDlet.java index 2ac04e6..0e3cade 100644 --- a/src/main/java/org/jboss/totp/TOTPMIDlet.java +++ b/src/main/java/org/jboss/totp/TOTPMIDlet.java @@ -238,12 +238,6 @@ public void pauseApp() { * @see javax.microedition.midlet.MIDlet#destroyApp(boolean) */ public void destroyApp(boolean unconditional) { - try { - save(); - } catch (Exception e) { - debugErr("Saving config in destroyApp failed: " + e.getMessage()); - error(e); - } refreshTokenTask.cancel(); timer.cancel(); notifyDestroyed(); @@ -543,20 +537,20 @@ private int addProfileToRecordStore(final byte[] configBytes) { * Removes record with given ID from a {@link RecordStore} with given name. * * @param storeName - * @param recordIdx + * @param recordId */ - private void removeRecordFromStore(final String storeName, final int recordIdx) { + private void removeRecordFromStore(final String storeName, final int recordId) { RecordStore tmpRS = null; + if (DEBUG) + debug("removeRecordFromStore - " + storeName + " - " + recordId); try { tmpRS = RecordStore.openRecordStore(storeName, false); - if (tmpRS.getNumRecords() > recordIdx) { - tmpRS.deleteRecord(recordIdx + 1); - } + tmpRS.deleteRecord(recordId); } catch (RecordStoreNotFoundException e) { if (DEBUG) debug("removeRecordFromStore - RecordStoreNotFoundException - " + storeName); } catch (Exception e) { - debugErr("removeRecordFromStore - " + e.getClass().getName() + " - " + storeName + " - " + recordIdx + ": " + debugErr("removeRecordFromStore - " + e.getClass().getName() + " - " + storeName + " - " + recordId + ": " + e.getMessage()); } finally { if (tmpRS != null) { @@ -564,7 +558,7 @@ private void removeRecordFromStore(final String storeName, final int recordIdx) tmpRS.closeRecordStore(); } catch (RecordStoreException e) { debugErr("removeRecordFromStore (close) - " + e.getClass().getName() + " - " + storeName + " - " - + recordIdx + ": " + e.getMessage()); + + recordId + ": " + e.getMessage()); } } }