Skip to main content
Participating Frequently
January 6, 2014
Question

PersistenceManager not loading Data after full restart of APP ( iOS / Android

  • January 6, 2014
  • 1 reply
  • 700 views

Hi everybody,

I have a problem using the PersistenceManager

It is a simple code saving a String and loading it later on demand:

Save:

FlexGlobals.topLevelApplication.persistenceManager.setProperty("Number", TA_Number.text);

FlexGlobals.topLevelApplication.persistenceManager.save();

Load:

var savedData:Object = FlexGlobals.topLevelApplication.persistenceManager.getProperty("Number");

TA_Number is a spark TextArea

Everything works fine as long the app is running (also in background). When I fully close the app and restart it, the values sometimes is loaded but at least after a couple of restarts the loaded Object is empty.

I also tried to use an instance of spark.managers.PersistenceManager;

Furthermore there is just one instance of the PersistenceManager within one view, if this is important.

Do I miss something?! I have the same behavior on Android 4.2 as well as on iOS 7.

I am using :

AIR 3.9

Apache Flex SDK 4.11

FB 4.7

Best Regards

Roman

This topic has been closed for replies.

1 reply

SaframanAuthor
Participating Frequently
January 14, 2014

Hey!

Finally I found the problem.

It came from my main mxml file ( TabbedViewNavigatorApplication ). There I created an instance of the PersistenceManager using the variable declaration. Furthermore, I tried to read some values from the memory using this PersistenceManager instance. The instance is fine but the “reading” killed all other savings (randomly, but usually all of them after a couple of restarts) of the persistence manager from previous app starts. The persistNavigatorState functionality was not working neither - after every full restart it started always with the first view.

As soon as I moved the memory access to a handler, for example the initialize handler, everything became fine.

Don’t know where it came from. Probably the memory access came too early at the app start process?

Here are the code examples: The first one didn’t work and killed all stored values. The Second was fine!

BAD:

<?xml version="1.0" encoding="utf-8"?>

<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="320"

persistNavigatorState="true"

initialize="initializeHandler()">

 

 

 

          <fx:Script>

 

                    import spark.managers.PersistenceManager;

                    public var persistenzManager:PersistenceManager = new PersistenceManager();

                    public var geraeteKlasse:Object = persistenzManager.getProperty("Variable ");

 

                    protected function initializeHandler():void

                    {

....

GOOD:

<?xml version="1.0" encoding="utf-8"?>

<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="320"

persistNavigatorState="true"

initialize="initializeHandler()">

 

 

 

          <fx:Script>

 

                    import spark.managers.PersistenceManager;

                    public var persistenzManager:PersistenceManager = new PersistenceManager();

                    public var geraeteKlasse:Object;

 

                    protected function initializeHandler():void

                    {

                              geraeteKlasse = persistenzManager.getProperty("Variable");

....