How best to rewrite a lwuit application from using RMS to use lwuit.io library?

Go To StackoverFlow.com

2

I've written an application in lwuit where I use the RMS to store thousands of records, each with a unique id. Now I want to port/rewrite it to use lwuit IO library to make it portable to CodenameOne, but I've run into some challenges:

  1. there doesn't seem to be a way in lwuit.io.Storage to delete a record like in RMS (I can create and retrieve them using Storage.writeObject and readObject, but not get rid of them again)
  2. when I write records with writeObject, they're given a name (String), but there is no way I can retrieve the list of names to make sure I retrieve all of them again. With RMS I can get the total list.
  3. I'd like to use lwuit.io.CacheMap, but haven't been able to find an example or tutorial showing how to use it with io.Storage (the lwuit development guide doesn't even mention Cachemap)?

I'd appreciate tips on how to achive good performance with io library when I have thousands of records that may be stored and retrieved frequently and independently (beyond using CacheMap of cause ;-)

Maybe I've missed something, but it seems that without the above features, porting from RMS to lwuit.io is not straightforward.

2012-04-04 21:38
by user1246562
FYI if the documentation stumbled you in some way please file a bug on it with suggestions for improvement. Thanks - Shai Almog 2012-04-05 10:52
This link is also very useful :

http://stackoverflow.com/questions/11275975/how-to-use-codename-one-storageNikhil 2012-07-23 09:43



1

Spent the night, read the code instead of the documentation and realized that I misunderstood how Storage works ;-). When it talks about filenames, it is not actual (RMS) files, but entries into the RMS. So, to answer my own questions: 1) delete using deleteStorageFile(name); 2) use listEntries() ; 3) CacheMap is actually automatically used when using Storage, so no need to code it yourself. WIth this in mind, performance will be similar to RMS (probably better if you didn't use any caching before).

2012-04-05 06:28
by user1246562
Ads