You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Saframan <sa...@outlook.com> on 2014/01/06 15:30:12 UTC

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

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.

Best Regards 
Roman





--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PersistenceManager-not-loading-Data-after-full-restart-of-APP-iOS-Android-tp4340.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

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

Posted by Alex Harui <ah...@adobe.com>.
Hmm.  Could be timing like you are suggesting.  You could stick some
breakpoints on PersistenceManager and get a better sense of what it is
doing.

On 1/14/14 1:10 AM, "Saframan" <sa...@outlook.com> wrote:

>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");
>
>
>
>
>--
>View this message in context:
>http://apache-flex-users.2333346.n4.nabble.com/PersistenceManager-not-load
>ing-Data-after-full-restart-of-APP-iOS-Android-tp4340p4454.html
>Sent from the Apache Flex Users mailing list archive at Nabble.com.


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

Posted by Saframan <sa...@outlook.com>.
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");




--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/PersistenceManager-not-loading-Data-after-full-restart-of-APP-iOS-Android-tp4340p4454.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.