Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 88
Registered: ‎07-11-2009
My Device: Not Specified

Best Practice: Storing App Settings

My application will come with default settings that the users may edit and IMPORTANTLY the app may automatically download crucial settings from the web.  Should I use a persistable object?  XML file input/output?  or is there something else that I should be using?
Developer
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: Best Practice: Storing App Settings

[ Edited ]

I'd use the PersistentStore. Make an Object that holds all of your settings, then save the object to the persistent store. That way in the future if you make the app download info, you can set the object and save it easily, regardless of the type you are sending to the device, just parse it into the object and save.

 

 

import net.rim.device.api.system.PersistentObject;
import net.rim.device.api.system.PersistentStore;


public class LoadSaveOptions
{
private static PersistentObject _persist;
private static final long PERSIST = //some long data;

public static void Save(Options opt)
{
/// save the object
}

public static Options Load()
{
Options opt = new Options();

/// load the object

 

  //return

return opt;
}
}

 

 

 

 

 

Message Edited by footose on 08-05-2009 11:22 AM
Developer
Posts: 16,786
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Best Practice: Storing App Settings

if you use a self-defined object that implements persistable your settings will be deleted every time the app is removed or replaced.
you can use classes that already implement persistable like vector, hashtable, string etc if you want the store to remain.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
Developer
Developer
Posts: 321
Registered: ‎05-26-2009
My Device: Not Specified

Re: Best Practice: Storing App Settings

I store options as an XML file in RMS.

Your options are:

 

  • RMS
  • Persistent Store
  • Some file in device memory/SDCard. 


I chose RMS becaue its a J2ME standard and gives not performance/other problems for tasks like applicaiton preferences etc.

 

--MB.