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

Posts: 1,204
Registered: ‎12-29-2010
My Device: PlayBook, Z10 LE, Dev Alpha C

Persistence with SharedObject and fresh install/first-use behavior

For folks using SharedObject for persisting app settings, if you have built and tested the Starship Settings sample app, you may have noticed that the default slider settings as well as the warp image animation don't work correctly on a fresh install of the app.   This is because on a fresh install, the starshipSettings SharedObject does not exist, but it is read and used by the loadSettings() function.  This is a separate issue from the inadvisability of saving app settings only on exit discussed in this thread.  I patched in an example of how I handled default settings for a fresh install in a simple app.  Code changes can be found on my fork as of now, and/or if my pull request gets merged, in the main repo in the future.  Note that this is just one way to handle default settings on a fresh install when you use SharedObject for persistence; I used this because it it cleanly puts all default values in one place in my code, and greatly reduces the need to check every setting for null all over my code, just to handle the first-use scenario.  It may not be the best solution if you have a huge number of default settings.