Note that there are some explanatory texts on larger screens.

plurals
  1. POcodenameone - Storage file doesn't delete
    primarykey
    data
    text
    <p>I've added storage file to my codenameone application. In some event I wanna delete specific storage file and recreate it with some old filtered data and new data. It doesn't work well on deletion.</p> <p>First I create method for clear storage file in StorageManager class:</p> <pre><code>public void clearData(String pStorageTable){ Storage.getInstance().deleteStorageFile(pStorageTable); } </code></pre> <p>In other class I use this method like this: </p> <pre><code>// load all data of specific storage file // ... new DBManager().clearData(ThreeTrans.DB_NAME); // write old data with filtering of specific ID and new data // ... </code></pre> <p>here is method of write data:</p> <pre><code>public void write(ThreeTrans pTT){ if(store == null) { store = Storage.getInstance(); } DB_NAME = "TT"; if(!store.exists(DB_NAME)) { Hashtable depHash = new Hashtable(); String k = "1" + pTT.getNumber(); depHash.put(k, pTT.toString()); store.writeObject(DB_NAME, depHash); } else { Hashtable depHash = (Hashtable)store.readObject(DB_NAME); if (!depHash.containsValue(pTT.getNumber())) { String k = String.valueOf(getLastKeyNumber()); depHash.put(k, pTT.toString()); store.writeObject(DB_NAME, depHash); } } } </code></pre> <p>at first I was using this method for delete storage file:</p> <pre><code>public void clearData(String pStorageTable){ if(store == null) { store = Storage.getInstance(); } for (String str : store.listEntries()) { if(str.toLowerCase().startsWith(pStorageTable)) { store.deleteStorageFile(str); } } } </code></pre> <p>and after this problem this method changed to this;</p> <pre><code>public void clearData(String pStorageTable){ Storage.getInstance().deleteStorageFile(pStorageTable); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload