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

Adobe AIR Development

Reply
New Developer
Posts: 8
Registered: ‎12-18-2010
My Device: Not Specified

Saving User Settings/Preferences

[ Edited ]

Hi,

 

I was wondering what is the recommended way of saving user settings or preferences (that is, persisting settings/preferences so that they can be restored in the future). Is there BlackBerry API for doing that, or should we just use SQLLite database that came with AIR? Thanks in advance for your help.

Developer
Posts: 167
Registered: ‎12-17-2010
My Device: Bold 9000
My Carrier: Vodafone

Re: Saving User Settings/Preferences

Hi franse,

 

As far as I know you should use the SharedObject class to store data persistently.

You can find many examples on the internet.

 

Regards,

Eugene

Eugene

My PlayBook App: Checklists
Contributor
Posts: 22
Registered: ‎12-17-2010
My Device: Not Specified

Re: Saving User Settings/Preferences

Hello franse,

 

you can transparently serialize any object to the disk:

 

            flash.net.registerClassAlias("FooClass", FooVO);        
            var soSmiley FrustratedharedObject = SharedObject.getLocal("config");
            so.data.config = config;
            so.flush();

and read it again:


            flash.net.registerClassAlias("FooClass", FooVO);
            var soSmiley FrustratedharedObject = SharedObject.getLocal("config");           
            var foo:FooVO = so.data.config;

 

Marco

 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Saving User Settings/Preferences

You have many choices to pick.

 

SQLite db file if you have a lot of structed information to store, like game scores.

 

If you just have preference settings (maintain application state between sessions), you can also use XML.

 

Both these are good because they can be inspected outside the application when something does not seem right.

 

In all cases, preferences should be stored in the application storage directory.

 

Developer
Posts: 278
Registered: ‎10-27-2010
My Device: Playbook

Re: Saving User Settings/Preferences

I agree with jtegen, plenty of choices out there. I find the sqlite solution quick and easy, though.
--------------
kdittyr

Accepted PlayBook Applications:
HDB Converter -- Utilities/Calculators